I want to launch 'onclick' in new window
I have pieced together this code (I am learning JS as I go) for nice rollover table cells but need the onclick action to open the link in a new window
I have highlighted the incriminating text in bold below
Anybody know what I am missing here?
<title> Why wont the page load in new window?</title>
src.style.cursor = 'hand'; src.bgColor = clrOver;
src.style.cursor = 'default';
src.bgColor = clrIn;
<table width="100" height="20">
onMouseOut="mOut(this,'#EBEBEB');" valign=top bgcolor=#EBEBEB colspan=5><font color="#FF6666"></font></td>
|Paul in South Africa|
should work. This will open the page in a new window of the specified size with no toobar etc.
That was exactly what I needed :)
You could also put this script in a real HTML anchor to serve 2 purposes :
a) make it work for JS disabled browsers (about 8 % of market)
b) make this link readable by search engine spiders, so pop-up page is indexable
I use this in original page :
<a href="page.htm" onClick="window.open('page.htm','','scrollbars=XX,resizable=XX,
And this in pop-up <body> tag:
The reason that your code in the firsst post didn't work is that you are using a <TD.. tag, and, unlike the <A tag, the <TD tag doesn't have a target= attribute.
Just to add to Macguru's post:
then you don't need the onLoad=window.resizeTo(WWW,HHH); in your pop-up.
Then you won't need your <font color="#FF6666"></font> tag either.
I add window size in onload event because I want visitors to know they are in a pop-up when they open the page from a search engine. This may not be applicable to all cases...
It is also a good idea to add a link to a 'normal' page in the pop-up.
Correct me if I'm wrong but the code you have posted only works on text links?
I wanted a new window to open when the 'onclick' function was called anywhere over a table cell regardless of it's text content. This way I can save time making rollover images for a navigation menu and reduce download times of the page by having the rollover as JS.
Is it possible to do this so the link for the table cell will be spidered by SE's.
|"...I add window size in onload event because I want visitors to know they are in a pop-up when they open the page from a search engine..." |
>> The reason that your code in the firsst post didn't work is that you are using a <TD.. tag, and, unlike the <A tag, the <TD tag doesn't have a target= attribute.
I see that now :)
With the CSS, will it change the background of the entire table cell? or will it just change the background of the link text?
>>> "...With the CSS, will it change the background of the entire table cell?..."
Just the text in the <A> tag. And I don't think you can define :hover css properties for other tags, just for <A>. There are 2 things that you can do, however:
1. Define height and width css properties of the <A> tag to be 100% (i.e. 100% of what contains it, being the table cell). Not sure if it will work, or how browser dependant it is. You can try it.
2. And this one I am sure of... Between the <A> and the </A> define a "<div> your link text </div>". Then in the css you can define the size of the div to be whatever you want.
Will give that a go.
But I am no expert with CSS. One of the many things on my list of 'things to learn'. Problem is that list seems to get bigger, faster than I can tick em off.
C'est la vie :)
>>"..that list seems to get bigger.."
Me too. But the good news is that CSS is really easy. The other bit of good news is that technology changes so fast and technologies become obsolete, so if you don't get to half of the technologies in the list it doesn't matter. They'll be obsolete by the time you get to them. Problem is choosing which half ;)
Setting display: block on the anchor within the cell ought to give the same impression as the entire cell rolling over, iirc. Its been a while since I tried it.