Results 1 to 4 of 4

Thread: onclick pass url and execute remote script problem

  1. #1
    Join Date
    Jun 2010

    onclick pass url and execute remote script problem

    Hello all,

    I have a menu system that I want to be able to onclick pass a url to a <script></script> (located in the main content of the page) where the url passed replaces the 'src' of that script.
    The reason is because a lot of the links are syndicated content, and instead of having 10 or 20 extra pages just to load that content, I want to dynamically change the script src.
    I don't think it's passing my variable because it's a url or something.

    Help please?


    <!--script that does all the work-->
    <script type="text/javascript">
    function synchange(pass)
    var new_var = pass;
    document.getElementById("cursyncon").setAttribute("src", new_var);

    <!--menu part that activates the onclick and function, thus changing the content-->
    <li><a href="#" onclick="synchange('http://content.cdsbe.com/_utility/ibmrdr/www.live.hal.webcollage.net/server/yorel/hal-showcase?ws-entry=halsrv-i-series-landing-page')">System i</a></li>

    <!--goes in the main content junk where syndicated content shows up-->
    <script id="cursyncon" src="#"></script>

    thanks again for any help...!

  2. #2
    Join Date
    Jun 2010
    bump. if any insight, I would be very grateful...

  3. #3
    Join Date
    Feb 2006
    It doesn't matter where you put a script tag, if you insert it after the page has loaded.

    Replacing or removing a script element does not remove any loaded script, it just adds the script from the new source to the global object. The original script is still in existence, though the new code may overwrite or break it.

    You can add a new script element, but you cannot call any of its functions or use any of its objects until it is loaded and interpreted. You can use the script elements onload or readystatechange event, or use a timer to check for some property set in the script. If the script was on your own domain you could fetch it and run a callback with Ajax.

  4. #4
    Join Date
    Jun 2010
    thank you very much, I will look into those other ideas.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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