Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Turning frequently used code into a function


ocon - 1:16 pm on Oct 9, 2012 (gmt 0)


Right now there are just two forms, and that's all I can see in the near future.

I didn't think about that before, but should I just pass some kind of variable to the function to tell it which form I want to use it in and then use a switch inside the function for which part of the code to execute?

if(type){
var url = window.location.href.split("?");
var pr = url[1].split(/[&;]/g);
if(type==1) for(var i=0;i<pr.length;i++) if(pr[i].lastIndexOf("x=", 0)!==-1) pr.splice(i, 1);
else for(var i=0;i<pr.length;i++) if((pr[i].lastIndexOf("ll=", 0)!==-1) || (pr[i].lastIndexOf("m=", 0)!==-1) || (pr[i].lastIndexOf("a=", 0)!==-1)) pr.splice(i, 1);
window.location = (pr.length>0) ? url[0]+"?"+pr.join("&") : url[0];}


Thread source:: http://www.webmasterworld.com/javascript/4505715.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com