gpt4 book ai didi

Javascript 书签复制 URI/URL

转载 作者:行者123 更新时间:2023-12-03 02:18:21 25 4
gpt4 key购买 nike

我有以下书签:

javascript:findlink=document.getElementsByClassName(%22download_link%22)[2].href;window.open('https://myfiledrive.com/users/files/add?url='+findlink,'_blank');void(0);

示例:

<a class="download_link" href="example.com/pdf1.pdf">
<a class="download_link" href="example.com/pdf2.pdf">
<a class="download_link" href="example.com/pdf3.pdf">

基本上,它搜索当前事件页面,查找具有“download_link”类的标签的第三次迭代,并将其存储在变量“findink”中,

然后它加载'https://myfiledrive.com/users/files/add?url= '+查找链接

在上面的示例中,它应该加载:

https://myfiledrive.com/users/files/add?url=example.com/pdf3.pdf

但最终发生的是加载:

https://myfiledrive.com/users/files/add?url=example.com/pdf3.pdf?url=example.com/pdf3.pdf

  • 所以基本上它是重复的 url=

我做错了什么?谢谢。

最佳答案

url 参数不应重复。您没有附加到 findlink 或任何内容。您可以尝试下面的代码片段,它与您发布的完全相同。

Chrome 将阻止弹出窗口,但如果您阅读错误消息,则不会出现重复情况:

Blocked opening 'https://myfiledrive.com/users/files/add?url=https://stacksnippets.net/example.com/pdf3.pdf' in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.

无论我点击多少次,

url 都只会出现一次。

<a class="download_link" href="example.com/pdf1.pdf">1</a>
<a class="download_link" href="example.com/pdf2.pdf">2</a>
<a class="download_link" href="example.com/pdf3.pdf">3</a>

<a href="javascript:findlink=document.getElementsByClassName(%22download_link%22)[2].href;window.open('https://myfiledrive.com/users/files/add?url='+findlink,'_blank');void(0);">download</a>

关于Javascript 书签复制 URI/URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49268342/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com