javascript - JS return a link to the page with certain ID in it -


is there way javascript find page id on , return link page?

for example, if had paragraph tag id="test" on page called test.html javascript variable set link test.html because has id="test" on it.

i have explained badly wondering if possible.

thanks.

example of code on test.html

<p id="test"></p> 

it not perfect have found way (kind of) this.

html:

<input id="tosearch" type="text"> <button id="search" type="button" onclick="getsearch()">search ids</button> <p id="searchout"></p>  <script src="search.js"> </script>  <p hidden id=".id">examplepage.html</p> <p hidden id=".id2">examplepage2.html</p> 

javascript:

function getsearch() { var search = document.getelementbyid("tosearch").value; search = "." + search;  var page = document.getelementbyid(search).innerhtml; page = page.link(page); document.getelementbyid("searchout").innerhtml = page; } 

this allows search id , returns link page id have manually put ids , links in.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -