Results 1 to 2 of 2

Thread: javascript

  1. #1
    Join Date
    Jun 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default javascript

    i write this function the problem is when i calll it in an xslt file it runs without stop any idea what to do to return a value so it can run only once when i click into the link and not to run and do replace from th begining

    Code:
    function showAccessibleVersion(){
    	var location=window.location.href.replace("&accessibility=true","").replace("?accessibility=true","").replace("&accessibility=false","").replace("?accessibility=false","");
    	location+=location.substr(window.location.href.length-5,5)=='.aspx' ? '?accessibility=true':'&accessibility=true';
    	window.location.href = location;
    }

    thanks in advance
    csst9746
    Last edited by jscheuer1; 06-19-2008 at 03:13 PM. Reason: format code

  2. #2
    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

    Not knowing much about aspx, your code looks wrong to me. If it's meant to be just regular javascript, it could probably be improved significantly before worrying about fixing this problem.


    But to answer your question:

    Add another query to the URL (just as a flag) when it runs and test for it at the beginning of the function (before the flag is added). If it's there (which it would be on the second run through) return before processing further.
    - John
    ________________________

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

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
  •