user3330683 user3330683 - 5 months ago 45
Javascript Question

JS Bookmarklet for Searching page source for specific code

I am trying to create a JS Bookmarklet that will search the source of whatever page I'm on for a specific code (example. "G1_Value_client") and if that exists I want it to return an alert A and if it does not exist I want it to return alert B.

I am not sure where I am going wrong. Any help would be greatly appreciated!


Umm..Javascript Bookmarklets are written in javascript, not c#. Here's a sort of translation:

if(document.documentElement.outerHTML.indexOf("G5_CLIENT_TRACKING_ID") > -1) {
    alert("Core Site!");
} else {
    alert("Cloud Site!");