SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2005
    Posts
    436
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Loading External Content into Dynamically Created Div

    Hey,

    I'm trying to load external content (off-site) into a dynamically created div. The idea is I give a client a <script src='http://www.mysite.com/myjs.js'> tag they place within their code. I want my javascript to create a div immediately before or immediately after that script tag and then use AJAX to load data in. This is not fixed height data and it will expand based on user activity so an iframe is not an option.

    My major question is: how do I create that div dynamically?

    Also, please advise me if I am going about this completely wrong.

    Thanks,
    e39m5

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    When you have a reference to your script tag, you can place it dynamically with

    Code javascript:
    scriptTag.parentNode.insertBefore(myDiv, myScript);
    Last edited by paul_wilkins; Apr 13, 2008 at 18:59.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •