d-b
d-b

Reputation: 971

Access the source code of a webpage with a bookmarklet?

I want to take a string (an ID number) from the source code of a webpage and load a new (replace the current) web page using the ID.

In the source code of web page A there is a tag

<meta name="navId" content="123">

I want to extract 123 and then load the URL

https://example.com/data?id=123

Can this be done using a bookmarklet?

Upvotes: 0

Views: 304

Answers (1)

Rich Moss
Rich Moss

Reputation: 2384

If there's only one META tag, this might work: javascript:location.replace('https://example.com/data?id=' + document.getElementsByTagName("META")[0].content)

Try changing the [0] to [1] if it's consistently the second META tag.

Upvotes: 1

Related Questions