【问题标题】:Is there a way to create a iframe that asks for the url to embed?有没有办法创建一个要求嵌入 url 的 iframe?
【发布时间】:2022-10-24 23:09:04
【问题描述】:

如何为带有输入消息的 URL 制作可自定义的 iframe,这样您就不必返回代码来输入新的 URL?我被困住了。

仅供参考,我是初学者 JS 和 HTML 编码器

这是我到目前为止得到的

javascript:document.title=prompt('Welcome to the GG Bypass setup!\n\nEnter the URL you want to unblock:');((function()%7Bvar a,b,c;c="input",b=document.createElement("iframe"),b.setAttribute("src",c),b.setAttribute("id","rusic-modal"),b.setAttribute("style","position: fixed; z-index: 999999; y-index: 9999999; x-position: 0; y-position 0; width: 100%; height: 100%; right: 0px; top: 0px; left: 0px; bottom: 0px; border: 0px solid #000000;%20overflow:%20hidden;%20background-color:%20#fff;%22),a=document.getElementsByTagName(%22body%22)%5B0%5D,a.appendChild(b)%7D)).call(this)

它会给你一条消息,以及输入网址的区域。但之后,没有出现 iframe。并且选项卡的名称成为 url 和分页符

【问题讨论】:

  • 取决于你的意思。您是想在每次使用 url 时在 <body> 中显示不同的消息,还是根据新消息创建一个全新的 url?对于前者,您可以使用prompt() 调用并使用其返回的字符串来设置<body> 的内容
  • 你能帮忙处理一下 prompt() 消息吗?

标签: javascript iframe


【解决方案1】:

// get elements
const input = document.querySelector('input')
const button = document.querySelector('button')
const iframe = document.querySelector('iframe')

// when button is clicked
button.addEventListener('click', () => {
  // set url
  iframe.src = input.value
})
iframe {
  display: block;
}
<input>
<button>change url</button>
<iframe></iframe>

【讨论】:

  • 你能运行 javascript,在 iframe 发生之前,我需要帮助创建一条消息,上面写着“要嵌入什么 URL”?然后单击“确定”,您想要的链接就会出现在同一屏幕上。
猜你喜欢
  • 1970-01-01
  • 2020-09-04
  • 1970-01-01
  • 1970-01-01
  • 2021-03-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-10
相关资源
最近更新 更多