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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write out a href with javascript when a page loads - is it possible?

Status
Not open for further replies.

Transcend

Programmer
Sep 29, 2002
858
AU
Hi guys -

the problem I have is this, when a certain page in my asp .net application loads, different things need to happen depending on who is logged in, what they are looking at etc etc.

In some instances on the page I write out a html table on the fly which works fine. Two of the columns need to contain a href which opens up another window. I can get the href to display and to open the other window fine. However I would like to be able to set the size, titlebar visible etc on this new page. Is it at all possible to do this? Is it possible using response.write to write out a href or some sort of javascript to enable this?

Please help!!

Transcend
[gorgeous]
 
This is more a Javascript question but yes you can. As you are already writing the anchor to the page then all you need to do is add an onclick attribute to the <a> tag which opens hte new window using Javascript.

The tag will look somethign like this.
Code:
<a href=&quot;#&quot; onclick=&quot;window.open(&quot;page.htm&quot;, &quot;windowName&quot;, &quot;width=400,height=200&quot;); return false;&quot;>my link</a>#

There are plenty of attributes of window.open method check out for a full explanation.

hth

Rob

------------------------------------

On with the dance! let joy be unconfined;
No sleep till morn, when Youth and Pleasure meet
To chase the glowing hours with flying feet.
-Byron

------------------------------------
 
In the off chance that you're adding the link in the code behind as either and html link control or an asp.net link button control, you can also add the onClick event from the codebehind.

linkButton.Attributes.Add(&quot;OnClick&quot;, &quot;window.open(...);&quot;)

D'Arcy
 
Hi jfrost

yes I am adding the link in the code behind .. i'll give that a try. Thanks

Transcend
[gorgeous]
 
Well ended up going down a completely different path in the end but thanks for the input guys

Transcend
[gorgeous]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top