How do you extract a URL argument from an HTML tag by using Javascript tokens? -


here string want extract after &key=f430a2c1 until &

is there way access data, extract key?

<img src="img/index.php?key=f430a2c1&rand=736920" alt= 

this string exists within document, , may need function grab src="" area.

i guessing want, maybe this?

var images = document.getelementsbytagname("img"),     wanted;  if (images.length) {     wanted = images[0].src;     if (wanted) {         wanted = wanted.split("?");         if (wanted.length >= 2 && wanted[1].indexof("&") !== -1) {             wanted = wanted[1].split("&")[0];         }     } }  if (typeof wanted !== "string") {     wanted = ""; }  console.log(wanted); 

output

key=f430a2c1  

on jsfiddle


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -