简体   繁体   中英

How to get the attribute value from parent page.I tried using opener and window.parent.But doesn't work

I am working on javascript and jquery. In page1 there is an edit symbol (which have "news" and "image" as attributes like, news="news1" image="image1.jpg" ).

When click on that symbol it takes us to the other page (in href i mentioned the page url).Now in this page2 i want to get those attributes. I tried as follows but doesn't work

How can i get those values..? I put that code in onload and document.ready

Consider sending values "news1" and "image1.jpg" to page2 as URL arguments:

<page2 URL>?news=news1&image=image2

Edited:

Can you place your data into hidden inputs inside a form, and use your link to submit it ( onclick="form.submit();" )?
This way you'll make a POST request instead of GET.

I think you can put the two attributes as parameters in the 'href' of the 'a' in page1; like:

href="xxx.com/xxx/?news=new1&image=image1" ;

and in page2 you can get the two parameters in the URL and then use it;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM