1

I am using the following JS function to open a pop-up window to display another website:

<script language="javascript" type="text/javascript">
function link()
{
 window.open("www.google.com")
}
onClick="Link()"

The URL in the above example is just for testing. I actually intend on replacing the URL with a text value from a listbox, which is in the form of a URL. Anyway, when ever I start the debugger in Visual Studio, and execute the onClick, the pop-up window opens and gives me a page stating that there is a server error. Specifically, Server error in '/' application... resource cannot be found. Also, I notice that my URL is placed as follows: http://localhost:49456/www.google.com. I thought this function would give me a pop-up window with Google as the website. Is this a Visual Studio debugger issue, is my code wrong, or am I using the code in the wrong context? Any suggestions would be greatly appreciated.

Jason Plank
2,3325 gold badges32 silver badges40 bronze badges
asked Jun 18, 2009 at 16:03

2 Answers 2

2

you need to specify http:// in the url eg

window.open("http://google.com");

without that protocol specified, the browser will think the URL is relative to the current document.

answered Jun 18, 2009 at 16:06
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you - I feel like such an idiot. Earlier, I was using "http//:", and it was not working so I decided to ask this question. Thank you Andy E
No worries, more people than you'd think have fallen into that trap, me included :)
1

Add http:// to your domain, i.e. http://www.google.com.

Jason Plank
2,3325 gold badges32 silver badges40 bronze badges
answered Jun 18, 2009 at 16:06

1 Comment

Thank you - Earlier I kept typing "http//:" and not realizing that the URL format was wrong. Thanks Josh,

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.