Bookmarklet not working as it should (i think)
Can someone tell me what I am doing wrong here...
This returns "Button Not Found"
javascript:var nam="http://apps.facebook.com/onthefarm/giftaccept.php?senderId=547766125&gift=haitibackpack_item_single&timestamp=1285776944&ref=gift_accept_tab&key=6870697de39960508737349c7a3f1363%24%24ggM3T%2CPU2YKM2l0mNrM%28U%28b%21eHAoclFCBgwg49%21S34GWkEXxTekFN_Fkx5%2AUZPcNMEOj&signature=a86a9e11aab0051e3fde676a9abe4283&srcapp=FarmVille"; nam="actions["+nam.replace(/\&/g, "&")+"]"; var els=document.getElementsByName(nam); if(els.length == 0) alert("Button not found"); else els[0].click();
This prompts me to enter a URL...I enter the EXACT same URL as in the above example and it works fine, clicks the button which brings me to the desired page.
javascript:var nam=prompt('enter URL Please'); nam="actions["+nam.replace(/\&/g, "&")+"]"; var els=document.getElementsByName(nam); if(els.length == 0) alert开发者_如何学编程("Button not found"); else els[0].click();
Thanks
Before you ask...I've tried in Chrome, IE and Firefox. It does not appear to be an issue with the length of the JS. I get the same results as above regardless of which (valid) URL I use. I am getting desperate here.
Well, it looks like you're trying to get a specific value within a page. It also looks that this value (nam
) is likely regenerated since it contains a timestamp and other properties that seem session based.
I'm of the opinion that your code works perfectly. Its the value that changes, so no match is ever found.
To be sure, we'd have to see the markup... and verify it was not changing
精彩评论