Hypertext Magic help needed

Ok, new plan. In chrome right click webpage, inspect -> console.

type: alert('hi');

You will see an alert, now you see we can do it just in the webpage, don't bother with codepen.

Look at the HTML source and find the element, does it have an id attribute? or a classname?

Now we have to get it programmatically.

Best case scenario is the element has an "id". Then you can use document.getElementByID('theId'). Sometimes you have to document.getElementsByClassName('className') -- this returns multiple elements, so you have to grab the 5th one or whatever index it is. There's also document.getElementById('a'); which will return all the "a href" tags, but you have to find the one you want because it returns multiple.

Now you have to get the URL. Here is an example:

var myRef =document.getElementById("aaa").getAttribute("href");

Now manipulate your string named myRef

and finally your redirect looks like this :

window.location.href = "http://www.google.com";

/r/webdev Thread Parent