473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

i do not understand this behavior: url tacked onto "localhost"

I'm trying to use a LinkButton with both an HREF and an OnClick to defeat
the popup blocker because we have a disproportionately high number of users
who won't know they have popups blocked or even know what a popup is. Our
site opens pages from our affiliates in a popup window.

Why do I get an error saying page http://localhost/www.msn.com cannot be
found? How is 'localhost' entering into the picture? I assume there's a
conflict between the href and the onclick? I'm running the page inside
Visual Studio .NET

In the HTML document:

<script language="javascript">

function LAUNCH(url) {
alert('launch');
window.open(url);

}
</script>

In the code behind:

Public Class WebForm1

Protected WithEvents LB As LinkButton
Private Sub Page_Load (....
LB = New LinkButton
LB.ID = "Test1000"
LB.Attributes("ctrid") = "2468"
Dim url As String = "ht" + "tp:\\" + "www.msn.com"
LB.Attributes("onclick") = "ja" + "vascript:LAUNCH('" + url + "');"
LB.Text = "This is a test link whose click should open a popup"
AddHandler LB.Click, AddressOf TestLinkButtonHandler
Me.Panel1.Controls.Add(LB)

End Sub

Private Sub TestLinkButtonHandler(ByVal sender As System.Object, ByVal e As
System.EventArgs)

End Sub
The rendered HTML:
<a id="Test1000" ctrid="2468"
onclick="javascript:LAUNCH('http:\\www.msn.com');"
href="javascript:__doPostBack('Test1000','')">This is a test--it should
open a popup</a>

Nov 19 '05 #1
1 2611
in javascript url = http:\\www.msn.com

\ is an escape character meaning the actual value is http:\www.msn.com

typically you escape a string in codebehind for use in javascript:

public shared function PrepareStringForJavascript(input as string) as string
if input is nothing then
return ""
end if
return input.replace("\", "\\").replace("'", "\'")
end if

so if you pass your dim url through this, it should work...

also slashes normally go the other way...http://www.msn.com which will also
solve your problem since / isn't a special character.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Timo" <Ti**@noneofyer.biz> wrote in message
news:Oy**************@TK2MSFTNGP09.phx.gbl...
I'm trying to use a LinkButton with both an HREF and an OnClick to defeat
the popup blocker because we have a disproportionately high number of users who won't know they have popups blocked or even know what a popup is. Our
site opens pages from our affiliates in a popup window.

Why do I get an error saying page http://localhost/www.msn.com cannot be
found? How is 'localhost' entering into the picture? I assume there's a
conflict between the href and the onclick? I'm running the page inside
Visual Studio .NET

In the HTML document:

<script language="javascript">

function LAUNCH(url) {
alert('launch');
window.open(url);

}
</script>

In the code behind:

Public Class WebForm1

Protected WithEvents LB As LinkButton
Private Sub Page_Load (....
LB = New LinkButton
LB.ID = "Test1000"
LB.Attributes("ctrid") = "2468"
Dim url As String = "ht" + "tp:\\" + "www.msn.com"
LB.Attributes("onclick") = "ja" + "vascript:LAUNCH('" + url + "');"
LB.Text = "This is a test link whose click should open a popup"
AddHandler LB.Click, AddressOf TestLinkButtonHandler
Me.Panel1.Controls.Add(LB)

End Sub

Private Sub TestLinkButtonHandler(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub
The rendered HTML:
<a id="Test1000" ctrid="2468"
onclick="javascript:LAUNCH('http:\\www.msn.com');"
href="javascript:__doPostBack('Test1000','')">This is a test--it should
open a popup</a>

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: aa | last post by:
Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini in php.ini I have: SMTP = localhost SMTP_PORT = 25...
5
by: Chris | last post by:
What is going on here... I have my site running locally on my machine, and when I don't have an internet connection (like when Im on the train) I get this error when I try to open an asp.net...
4
by: Greg Cyrus | last post by:
Hi, in a Page_Load I use: Response.Redirect("http://localhost/WebApplication3/frmDefault.aspx") Now the IExplorer shows "http://localhost/WebApplication3/frmKopf.aspx" in the adress-field....
3
by: Robin Tucker | last post by:
Should I consider this to work in other locales? If theServer.Name <> "(local)" and theServer.Name <> "(localhost)" Then ' Can only use local machine in this version..... End If
0
by: Durai | last post by:
Hello All, I built postgresql on HPUX IPF(11.22) platform. It works fine. But I have warning message "could not resolve "localhost": host nor service provided, or not known" when I start the...
3
by: Lee Roth | last post by:
I am testing a web app that links to user defined URLs. I want the link to be the exact text the user provided but I can't seem to get rid of the "http://localhost" prefix in the link. Note that I...
5
by: KenLee | last post by:
help: how can I change from "//localhost:numbers/" to just "//localhost/"? I can see the web pages using "//localhost:numbers/" instead of ""//localhost/". I use asp.net 2.o. and windows 2000....
12
by: Jonathan Wood | last post by:
Greetings, I wonder if anyone can help me with this. I have an XP laptop, and a Vista desktop computer. I use the laptop to run software remotely on the desktop using the Remote Desktop...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.