Javascript:在同一个窗口中打开新页面 [英] Javascript: open new page in same window

查看:122
本文介绍了Javascript:在同一个窗口中打开新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的方法可以修改此代码,以便在SAME窗口中打开目标网址?

Is there an easy way to modify this code so that the target URL opens in the SAME window?

<a href="javascript:q=(document.location.href);void(open('http://example.com/submit.php?url='+escape(q),'','resizable,location,menubar,toolbar,scrollbars,status'));">click here</a>``


推荐答案

window.open()的第二个参数是表示目标窗口名称的字符串。

The second parameter of window.open() is a string representing the name of the target window.

将其设置为:_ self。

Set it to: "_self".

<a href="javascript:q=(document.location.href);void(open('http://example.com/submit.php?url='+escape(q),'_self','resizable,location,menubar,toolbar,scrollbars,status'));">click here</a>



旁注:
以下问题概述了将事件处理程序绑定到HTML链接的更好方法。


Sidenote: The following question gives an overview of an arguably better way to bind event handlers to HTML links.

用js函数替换链接的最佳方法是什么?

这篇关于Javascript:在同一个窗口中打开新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆