【问题标题】:How can i take user input and save it permanently in a variable and use that variable in window.open()如何获取用户输入并将其永久保存在变量中并在 window.open() 中使用该变量
【发布时间】:2020-12-19 17:22:44
【问题描述】:

我正在尝试使用 javascript 获取在文本框中输入的 url 并永久更改变量。然后,如果条件为真,我想在带有 window.open() 的 if 语句中使用该变量。代码将是保存在他们计算机上的文件,他们在 chrome 中打开。有什么想法吗?

【问题讨论】:

  • 这个问题非常模糊。

标签: javascript if-statement variables url user-input


【解决方案1】:

将此变量保存在 localStorage (https://developer.mozilla.org/pl/docs/Web/API/Window/localStorage) 中,但您必须知道它不是永久性的。

用户下次打开页面时,可以通过js获取这个变量。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多