简体   繁体   中英

How to pass and display the js variable value into html page?

I have a Javascript file (which will start when invoked from my application when the user selects an item in my application).
In that file I have a variable and am storing a large, dynamic string (based on the user selection) in that variable.

Now I want to open a new page from the Javascript and display the value stored in the string variable in that page.

How do I pass the variable value and display it in that page?

I can use window.open() to open a new window.

Step1

Open the new window like below

newWindow = window.open('newpage.html',/* other parameters */);

Step2

write a function in the new window

function passValue(val){
// do stuff
}

Step3

once the window is open , call the function to pass the value like below

newWindow.passValue('your value')

You are done..!!

Cheers

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