2017-08-01 36 views
0

JavaScript是否便于将内容携带到另一个页面,然后执行一些操作。我还没有找到任何相关命令,允许我在重定向页面上执行操作。将内容携带到下一页

从本质上讲,我以下(用例的例子)后:

  • 页是创建基于一些 标准的用户选择
  • 一个简单的文本句子发电机一旦用户点击“转到”,页面重定向到 具有单个文本框和按钮
  • 自动填充该文本框的内容和提交
另一页3210

这可能吗?

+1

你也许可以使用诸如GET和Post之类的东西吗? –

+0

如果它在同一个域中,甚至cookie或localstorage可能会工作 –

+0

您可以使用'querystring'使用JavaScript,您可以在下一页获得内容 –

回答

2

如果您使用Javascript功能来将用户重定向到新的页面,你可以设置全局变量,像这样的新窗口,

// Save the reference to the new window in a variable 
var redirect = window.open('http://www.example.com'); 

//form the variables as an object 
var variables = { 
    var1: "First Value", 
    var2: "Second Value", 
    ... 
} 

// Send the variables to new page 
redirect.variables = myVariables; 

然后在新的页面,你可以做

console.log(window.variables.var1); //will give "First Value" 
console.log(window.variables.var2); //will give "Second Value" 
+0

谢谢Jay。但是,我需要在下一页上有一个JavaScript的权利?无法将其加载到“缓存”本身 – NickP

相关问题