书签需要Javascript帮助
嘿,我有一个小小的javascript书签书签需要Javascript帮助,javascript,url,bookmarks,Javascript,Url,Bookmarks,嘿,我有一个小小的javascript书签 javascript:(函数(){window.open('http://www.mywebsite.com/index.php?currentsite#bookmark“);})( 如何将当前网站的url转换为该url? 我听说过使用document.URL,但我不知道如何将其与当前浏览的站点的URL一起放入书签中的URL中。意味着此时结果是http://www.mywebsite.com/index.php?currentsite=document
javascript:(函数(){window.open('http://www.mywebsite.com/index.php?currentsite#bookmark“);})(
如何将当前网站的url转换为该url?
我听说过使用document.URL
,但我不知道如何将其与当前浏览的站点的URL一起放入书签中的URL中。意味着此时结果是http://www.mywebsite.com/index.php?currentsite=document.URL#bookmark
谢谢试试看
window.location或document.location.href或window.location.href
我忘了哪一个有效:)只需使用window.location.href-如下所示:
window.open( 'http://<someurl>?' + window.location.href + '#somebookmark' );
function(){
var url = document.location.href;
window.open('http://www.mywebsite.com/index.php?currentsite = ' + url);
}
window.open('http://?'+window.location.href+'#somebookmark');
window.location.href将为您提供当前帧的href。尝试使用此选项:
javascript:( function(){window.open('http://www.mywebsite.com/index.php?'+document.location.href+'#bookmark');} )()
我不太清楚你在说什么,但是如果你想在anker上获得完整的URL,你可以
document.location.href
您可以使用Location对象访问URL的各个部分
您的代码应该如下所示:
window.open( 'http://<someurl>?' + window.location.href + '#somebookmark' );
function(){
var url = document.location.href;
window.open('http://www.mywebsite.com/index.php?currentsite = ' + url);
}
我不确定这是否是你想要做的。这并不能真正回答我的问题。谢谢。假设当前位置也有查询参数?:)