Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

innerHTML Javascript Issues. can anyone help?

0 views
Skip to first unread message

Pratik Patel

unread,
Jun 20, 2007, 2:10:42 AM6/20/07
to
Hello,

I used innerHTML to assign HTML content. but in my HTML page content
have also some javascript function and it will run when page load. bu
when HTML code assgin thru innerHTML then this javascript is not
working.

e.g.

html content:
.....................
<html>
<body>
<table>
<tr><td>
Some content here.
</td></tr>
</table>
<script language="javascript">
alert("hi");
</script>
</body>
</html>

I am assign this html page in innerHTML content

document.getElementById('div1').innerHTML="<html><body><table><tr><td>Some
content here.</td></tr></table><script
language="javascript">alert("hi");</script></body></html>";

when i used direct html page it's given alert message. but when i used
theu innerHTML then it's not given alert message.

how i can execute javascript in innerHTML?can anyone help?

Regards
Pratik Patel

Rami Elomaa

unread,
Jun 20, 2007, 3:02:16 AM6/20/07
to
Pratik Patel kirjoitti:

> how i can execute javascript in innerHTML?can anyone help?

Wrong group dude. This is php, you wanted javascript. Better luck next time.

--
Rami....@gmail.com

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze

Pratik Patel

unread,
Jun 20, 2007, 5:21:40 AM6/20/07
to
On Jun 20, 12:02 pm, Rami Elomaa <rami.elo...@gmail.com> wrote:
> Pratik Patel kirjoitti:
>
> > how i can execute javascript in innerHTML?can anyone help?
>
> Wrong group dude. This is php, you wanted javascript. Better luck next time.
>
> --
> Rami.Elo...@gmail.com

>
> "Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
> usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze

I was post same topic in javascript group also. but PHP people also
known javascript. and I have this kind of issue in AJAX. so i post
this topic at here.

petersprc

unread,
Jun 20, 2007, 6:39:22 AM6/20/07
to
It would be easier to separate the text and the script and call eval
on the script part.

Problem is the browser can't be counted on to evaluate your embedded
scripts. Here's a workaround:

http://kratcode.wordpress.com/2006/03/07/javascript-script-execution-in-innerhtml-the-revenge/

Jerry Stuckle

unread,
Jun 20, 2007, 7:55:23 AM6/20/07
to

And the people who know javascript frequent the javascript newsgroups, also.

Please use the appropriate newsgroup. This is not it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================

Toby A Inkster

unread,
Jun 24, 2007, 4:52:31 AM6/24/07
to
Pratik Patel wrote:

> I was post same topic in javascript group also. but PHP people also
> known javascript. and I have this kind of issue in AJAX. so i post
> this topic at here.

Some PHP people speak French too, but this isn't the best group to turn to
when you want something translated for you.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 3 days, 12:31.]

A New Look for TobyInkster.co.uk
http://tobyinkster.co.uk/blog/2007/06/22/new-look/

0 new messages