Results 1 to 6 of 6

Thread: How to run Javascript in <div> tag <div> </div>

  1. #1
    Join Date
    May 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to run Javascript in <div> tag <div> </div>

    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.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    javascripts from the second page aren't working? Yeah... you need to include them differently.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    May 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wink

    You can show me, how to run javascript in div tag....Please...

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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 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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    May 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •