如何使用javascript ...打开带有网址的新窗口? [英] How to open a new window with url using javascript...?

查看:63
本文介绍了如何使用javascript ...打开带有网址的新窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好朋友,我想在我的链接按钮上单击,使用javascript打开一个新窗口..


我用了它,它会很好用的..

.......
window.open(``http://www.google.com'',``mywindow'',``width=400,height=200'');
.......


但是我想要的是我需要打开一个带有url的窗口,但它不包含http://,这意味着它只能以www.google.com开头,如下所示:

.......
window.open(``www.google.com'',``mywindow'',``width = 400,height = 200'');
.......


请帮我...


谢谢... !!!!
Tejas Vaishnav

Hello friend i want to open a new window on my link button click using javascript..


i used this and it will work well..

.......
window.open(''http://www.google.com'',''mywindow'',''width=400,height=200'');
.......


but what i want is that i need to open a window with url but it will not contain http:// means it will be start with only www.google.com as shown under

.......
window.open(''www.google.com'',''mywindow'',''width=400,height=200'');
.......


please help me...


thank you...!!!!
Tejas Vaishnav

推荐答案

在浏览器中没有Http的情况是不可能的.因此,协议很重要.只有Chrome才能接受.
With Out Http in Browser it is not Possible.Protocol is important so. Only Chrome will accept.


嗯,我不认为您了解WWW的工作原理. "http://"是协议标识符,它还向浏览器说明您要打开的URL是绝对的.没有协议标识符的URL被视为相对URL,因此它将尝试打开http://yoursite.com/folderyouwerein/www.google.com(失败).

如果浏览器显示完整的URL(包括协议说明符)使您不满意,那么请克服它.那就是浏览器的功能(Chrome浏览器除外,Chrome在最新版本中未显示).
Um, I don''t think you understand how the WWW works. The ''http://'' is a protocol identifier, and it also explains to the browser that the URL you are asking it to open is absolute. A URL without a protocol identifier is taken as relative, and therefore it will try to open http://yoursite.com/folderyouwerein/www.google.com (and fail).

If you''re upset by the browser displaying the full URL (including the protocol specifier) then, well, get over it. That''s what browsers do (except Chrome which doesn''t show it in recent versions).


window.open('http://blahblah.com/mypage.aspx', target='new');



编辑=====================

告诉我为什么这是错误的,我将对其进行修复或删除,但不要只是在没有任何解释的情况下将其投票1.



EDIT =======================

Tell me why this is wrong, and I''ll either fix it or delete it, but don''t just vote it 1 without an explanation.


这篇关于如何使用javascript ...打开带有网址的新窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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