Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening New Window Sending Internet Link Through href 1

Status
Not open for further replies.

thunderain

Programmer
Jan 10, 2002
40
CA
Hi people:

I have been fighting with this for quite some time, should be a simple thing to do but i can't get it working. I need to send an internet link through and href, pick it up in javascript in head and open the internet page in a separate window.

This code can be copied into an asp file called "testsiteNewWindow.asp".

Here is full code:

<% @Language=&quot;VBScript&quot; %>

<html>
<title></title>
<head>
<script language=javascript>
<!-- Begin
var pagelink;
var url;
var msgWindow;

function internetlink(pagelink)
{

url = ( pagelink );

msgWindow = window.open(&quot;&quot;,&quot;internetlink&quot;,&quot;menubar=no,scrollbars=no,status=no,resizable=yes,width=450,height=450&quot;)
msgWindow.location.href = url

};

// End -->
</script>
</head>

<body>

<%
Dim pagelink

pagelink = &quot;Response.write &quot;<A href='testsiteNewWindow.asp' onClick='internetlink(pagelink)'>Open Window</a>&quot; & &quot;</td>&quot;
%>

</body>
</html>

If you replace:
url = ( pagelink );
with:
url = &quot;in the javascript in the head, then it works fine, but i can't do this, i need to sent the link from the body because when i get it working i will be calling the link up from a database.

If anyone can see what's wrong, or copy code and test it, will be appreciated

thank you
thunderain
 
If you have the link on database then you should just open the link as it should
Code:
function internetlink(pagelink)
    {    
     url = ( pagelink );
     msgWindow = window.open(url,&quot;internetlink&quot;,&quot;menubar=no,scrollbars=no,status=no,resizable=yes,width=450,height=450&quot;)   
    };
    
and now use 

internetlink(<%=Server.UrlEncode(myLink&quot;)%>)

Maybe you need to encode your link before adding to the link string

________
George, M
 
yes an small error
Code:
 should be

internetlink('<%=Server.UrlEncode(myLink&quot;)%>')

________
George, M
 
Still havn't got this to work

I have this in my head right now:


<script language=javascript>

<!-- Begin


var pagelink;
var url;
var msgWindow;

function internetlink(pagelink)
{
url = ( pagelink );

msgWindow = window.open(&quot;&quot;,&quot;internetlink&quot;,&quot;menubar=no,scrollbars=no,status=no,resizable=yes,width=450,height=450&quot;)
msgWindow.location.href = url

};

// End -->
</script>

This is my link at bottom:

<% pagelink = &quot; %>

<A Class=paging href='brandserv-list.asp?pagelink=<%= pagelink %>&' onClick=internetlink('<%=Server.UrlEncode(pagelink)%>')>Get Url</a></td>

The new window comes up with page cannot be displayed error.

Thanks
thunderain
 
Tryed to use my function?
Code:
function internetlink(pagelink)
    {    
     url = ( pagelink );
     msgWindow = window.open(url,&quot;internetlink&quot;,&quot;menubar=no,scrollbars=no,status=no,resizable=yes,width=450,height=450&quot;)   
    };

________
George, M
 
i copied your function in and still getting &quot;The page cannot be found&quot; in the new window coming up, do you see anything wrong with my href line at bottom? I have the Server.UrlEncode in place but the url simply is not getting through intact, i am baffled.

thanks....thunderain
 
Ok, i've made an example. It looks like Server.UrlEncode trigered the error.

Code:
<%
 pagelink = &quot;[URL unfurl="true"]http://www.heinz.com&quot;[/URL]
%>
<script language=javascript>
function internetlink(pagelink)
{    
	url = ( pagelink );
    msgWindow = window.open(&quot;&quot;,&quot;internetlink&quot;,&quot;menubar=no,scrollbars=no,status=no,resizable=yes,width=450,height=450&quot;)
    msgWindow.location.href = url
    
};
</script>
<a href=&quot;'brandserv-list.asp#?pagelink=<%=pagelink %>&&quot; onClick=&quot;internetlink('<%=pagelink%>')&quot;>Get Url</a>

________
George, M
 
Oops take off the quote from

href=&quot;'brandserv-list

________
George, M
 
thank you so much shadow, been fighting with this for quite sometime...this works perfectly....thunderain
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top