我有一个使用window.location的javascript函数.它适用于Firefox和Internet Explorer,但不适用于Chrome.我已经在Ubunutu Hardy和Windows Vista上测试了这个.底层问题是什么,我该如何规避呢?
你能告诉我为什么window.location.href不在firefox上工作吗?
码:
<script>
function goToURL() {
window.location.href('url');
}
</script>
Run Code Online (Sandbox Code Playgroud)
我可以使用什么而不是window.location.href替代品?
我想编写一个Greasemonkey /用户脚本,该脚本会自动添加.compact到以https://pay.reddit.com/开头的URL,因此它会自动将我重定向到移动版本。
我一直在寻找类似的用户脚本,尤其是以下用户脚本:https ://userscripts.org/scripts/review/112568 试图弄清楚如何编辑替换模式,但是我在这一领域缺乏技能。
如何编写将我从重定向https://pay.reddit.com/*到的Greasemonkey脚本https://pay.reddit.com/*.compact?
谢谢
我正在尝试用javascript做一些事情(我是初学者,我正在研究它),我想知道如何打开保存在变量中的链接.我正在尝试......
<input type="button" onclick="document.location.href=Query;" />
Run Code Online (Sandbox Code Playgroud)
其中Query是Ricerca方法中的一个变量,它与另一个按钮一起使用
function ricerca()
{
var Link = "http://www.mysite.com/search?q=variabile&k=&e=1";
var Name= document.getElementById('utente').value;
var Query = Link.replace("variabile",Name);
alert(Query);
return false;
}
Run Code Online (Sandbox Code Playgroud)
另一个按钮生成自定义搜索链接...
input type="text" id="utente">
<input type="submit" value="Click me" onclick="return ricerca();" />
Run Code Online (Sandbox Code Playgroud)
我的代码出了什么问题?
javascript ×3
url ×2
browser ×1
firefox ×1
greasemonkey ×1
html ×1
hyperlink ×1
redirect ×1
tampermonkey ×1
userscripts ×1