View Full Version : javascript

06-19-2008, 02:04 PM
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

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

06-19-2008, 03:21 PM
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.