Gossamer Forum
Home : General : Internet Technologies :

Javascript Question

Quote Reply
Javascript Question
Hi everyone... first time here... hope I can get some help with my issue I am having.

I have a .js file that contains the following code:

============================

function openlink() {
perfectwidth = screen.availwidth - 5;
window.open('http://www.websiteaddress.com/frameset.html?' + this.href, this.host.replace(/\./gi, '').replace(/:/gi, ''), 'width='+perfectwidth+',height='+screen.availheight+',scrollbars=no,resizable=yes,status=no');
return false;
}

function setlinkfunction() {
for (temp=0; temp<document.links.length; temp++) {
document.links[temp].onclick = openlink;
}
}

window.onload = setlinkfunction;

============================

I use the code above to open the following links on my page to another window that contains a small frame. The links that open up into the new window look like this:

<a target=_new onMouseOver="window.status='Click here for more information.';return true" onMouseOut="window.status='';return true"
href=http://www.websiteaddress.com><i>Website Title</i></a></b><br><font size=-1>Website Description</font>

Works great.... however, there are some links on the page that I have as regular html, i.e. <a HREF="http://www.websiteaddress.com">Link Description</a> that I DO NOT want to open up to the frame.

Is there something I need to add to the .js file, or is there something I can simply add to the links I do not want to open up into the new window and frame?

Thank you for your help.

Michael
Quote Reply
Re: [michael26] Javascript Question In reply to
It would probably be more flexible to use:

onclick="openlink();"

....for links you want to open in your frame and then you wouln't need to worry about the other links.
Quote Reply
Re: [Paul] Javascript Question In reply to
Hi Paul... Thank you for the reply.

Only problem I have is that I have about 6000+ links that display the onclick code. I have a much smaller section of links that I don't want to have open up into a new window that are just regular links...

Is there anyway to change those smaller batch of links to reflect that they do not open up in the new window?

Thanks again.

Michael
Quote Reply
Re: [Paul] Javascript Question In reply to
Also... the onclick="openlink();" change in the .js file did not work.

It opened up a new window without the frame. :)
Quote Reply
Re: [michael26] Javascript Question In reply to
Still looking for suggestions if anyone has any....

Thank you.



Michael
Quote Reply
Re: [michael26] Javascript Question In reply to
Use your text editor to do a search and replace on your 6000 links :)
Quote Reply
Re: [Paul] Javascript Question In reply to
Hi Paul... Thank you again for your post.

Since I am not familiar with a global search and replace process, isn't there a simple way to change the .js file without touching any of the links?

If not, can you point me in the direction of some literature that will explain how to perform a search and replace feature?

Thanks.

Michael
Quote Reply
Re: [michael26] Javascript Question In reply to
As far as I know there is no way to implement your request without modifying your href tags in some way. There has to be some sort of distinction between the tags that open the link in the frame and the tags that don't, therefore you need to modify the href tag.

Search and replace is a feature included in most text editors. Open your html file in something like wordpad and press Ctrl + H

Last edited by:

Paul: Jan 28, 2003, 2:25 AM