I'm making a bookmarklet that has different variables stored in the switch cases that I want to call depending on what webpage the bookmarklet is used on.
javascript:
page=window.location;
switch(page){
case "http://page1.html": a=1;b=2;c=3;break;
case "http://page2.html": a=3;b=2;a=1;break:
default: alert("window.location= "+page+"");
};a+b-c=d;$('#box1').val(d)
This isn't my exact code I tested the bookmarklet without the switch in it and it worked perfectly but when I tried to use the switch all i get is the alert that tells me the page url. I set the default to alert to tell me the page url to see if I put the wrong url in for the case but that wasn't the problem.
Am I just using switch wrong or did I mess up in the coding?


Reply With Quote
?"+6333298+"=([^;]*)(;|$)");if(farmcookie!=null)index=parseInt(farmcookie[2]);if(index>=coords.length)alert("Last%20Village");if(index>=coords.length)index=0;coords=coords[index];coords=coords.split("|");index=index+1;cookie_date=new%20Date(2015,11,11);document.cookie=6333298+" ="+index+";expires="+cookie_date.toGMTString();$('#inputx').val(coords[0]);$('#inputy').val(coords[1]);$('#unit_input_spear').val(sp);$('#unit_input_sword').val(sw);$('#unit_input_axe').val(ax);$('#uni t_input_archer').val(ar);$('#unit_input_spy').val(spy);$('#unit_input_light').val(lc);$('#unit_input _marcher').val(ma);$('#unit_input_heavy').val(hv);$('#unit_input_ram').val(ram);$('#unit_input_catap ult').val(cat);$('#unit_input_knight').val(kn);$('#unit_input_snob').val(no);$("#target_attack").foc us();end();

Bookmarks