View Full Version : How to run Javascript in <div> tag <div> </div>
texudp
05-16-2006, 12:01 AM
I load a page in <div> tag: document.getElementbyID("loadpage").innerHTML = ajaxload("page1.html")
If I open page1.html alone, everything is ok, javascript run well.
But when I load it into <div> tag, javascript code cannot display.
You can help me? Thanks.
djr33
05-16-2006, 01:29 AM
javascripts from the second page aren't working? Yeah... you need to include them differently.
texudp
05-16-2006, 04:02 AM
You can show me, how to run javascript in div tag....Please...:(
jscheuer1
05-16-2006, 04:08 AM
Looks like this belongs in the DynamicDrive Scripts help section but, don't worry about that. The moderator will move it if he agrees with me. Anyways, if it is a DD script:
Warning: Please include a link to the DD script in question in your post. See this thread (http://www.dynamicdrive.com/forums/showthread.php?t=6) for the proper posting format when asking a question.
And, in any case:
Please post a link to the page on your site that contains the problematic script so we can check it out.
djr33
05-16-2006, 05:19 AM
You sent me a message on Yahoo about this... but you're not on right now.
So... simple answer:
1. If YOU are in control of the page that is being put into the <div> tags, then you can do it.
2. If you are not, then it is either not gonna happen or really complex.
1. Just put the script in an external .js file and call it in the head section of both the page being called and the main page. Well... kinda, actually. You shouldn't call it in the page being called unless you want it to be called twice when it's included... that might cause problems.
Do you ONLY want it included, not by itself? that would really simplify things.
2. If you aren't in control of the second page, you'll have issues. You need to put it into an iframe, or, perhaps, write really complex JS that controls the content it gets from the page and modifies the script and other content to work within the main page.
Really, it's a complex problem that needs to be dealt with with a link to your page as john says.
In the end, the easiest way is just to use an iframe.
texudp
05-16-2006, 08:25 AM
Sorry about that
This is url: http://showroom.5gigs.com/Nhac/
This is site of music.
In the left div, it display singer or music group. When you click "toàn bộ nhạc phẩm", you get all the songs of this singer or this music group, they will display in middle div (id="rightcolumn").
And I want when click a song, it will play in the right column (id="playercolumn"), but it display nothing.
And this is the source of HTML page that I want to display in div(document.getElementbyID("playercolumn").innerHTML = ...: ex
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><title>Nhac - Nhac </title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link href="Library/nhacso.css" rel="stylesheet" type="text/css"/>
<script language="JavaScript" src="Library/nhacso.js"></script><script language="JavaScript" src="Library/script.js">
</script><script language="JavaScript" src="Library/vietuni.js"></script></head><body><table align="center" width="1" height="1" cellpadding="2"><tr><td><div id="vietkar9">
<span></span><span></span><span></span><span></span><span></span><span></span>
<script language="javascript" type="text/javascript">
document.write(showPLayerz('115`115`121`64`53`53`56`55`54`52`56`58`59`52`56`58`52`55`54`53`83`123`121`111`105`53`84`110`103`105`90`120`123`90`111`116`110`53`78` 123`127`107`116`74`111`107`123`90`110`123`101`74`117`116`109`74`103`117`53`125`115`103`53`54`57`101`78`123`127`107`116`74`111`107`123`90`110`123`101`86`110`117` 92`103`116`109`101`74`123`127`90`110`103`111`52`125`115`103`'));
// ratingShowResult(5, 5);
// Parse URL
var l = self.location + ''; l = l.split('/Music/Song/'); l = l[l.length-1];
var song_url = l;
</script>
</div>
</td></tr></table></body></html>
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.