Click to See Complete Forum and Search --> : Javascript Question


michael26
01-29-2003, 06:23 AM
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 links, 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

michael26
01-29-2003, 07:19 AM
Hi Dave.

Thank you for your quick reply.

The target="_self" didn't work with the links I didn't want to open up into a new frame.

Any other suggestions? Your help is really appreciated.

Thanks again.

Michael

michael26
01-29-2003, 07:57 AM
Would your suggestion be that I rewrite the .js file?

michael26
01-29-2003, 06:45 PM
Hi Dave,

I am still uncertain what you mean about target property.

Michael

michael26
01-29-2003, 08:38 PM
I modified the code you provided (Thank you by the way Dave), however, I have three problems now.

First, it shows done, but with errors on page.

Second, it does open the links with the onclick code, but it does not display the frame.

Third, I don't need the target="__self" as it does not open the links into new windows, but does display an error notification (done, but with error on page). I did try it with and without target="_self" and it shows the error, but hey, it doesn't open up into a new page.

I am just stuck. I have been reviewing this code all day. It shouldn't be this hard should it?

Thanks for all your help.

Michael

P.S. I have included what my other files are.. I hope this will solve the mystery.

Top Frame: top.html
=====================
<html>
<head>
<title>frameset top</title>
<script>
function removeframe() {
parent.document.location.href = parent.targeturl;
}
</script>
<style>
a {text-decoration: none}
a:hover {text-decoration: underline}
td {height: 16px; text-align: center; font: 7.5pt verdana; color: #000000; background-color: cccccc; white-space: nowrap}
</style>
</head>
<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 link=000000 vlink=000000 alink=000000 bgcolor=999999>
<table width=100% border=0 cellpadding=0 cellspacing=1>
<tr>
<td> << <a target=_top href="http://www.website.com">Return to Main Website</a> </td>
<td width=75%><p><a href="Website Link Here" target="_blank">Website Title HereFor Details</a></p></td>
<td> <a href="javascript:removeframe()">Remove Frame</a> >> </td>
</tr>
</table>
</body>
</html>

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

Bottom Frame bottom.html
=========================
<html>

<head>
<title>frameset bottom</title>
</head>

<body onload="document.location.href=parent.targeturl;">

</body>

</html>
=========================

Frameset frameset.html
================================
<html>

<head>
<title>Frameset</title>
<script>
targeturl = window.location.search.substring(1);
self.moveTo(0,0);
</script>
</head>

<frameset rows="18,*" border=0 frameborder=0>
<frame src="http://www.website.com/top.html" name=frame_top border=1 frameborder=0 scrolling=no noresize marginwidth=0 marginheight=0>
<frame src="http://www.website.com/bottom.html" name=frame_bottom border=0 frameborder=1 scrolling=auto noresize marginwidth=0 marginheight=0>
</frameset>
</html>
=================================

michael26
01-29-2003, 10:58 PM
My error logs for my website show:

The file does not exist:

It displays my links, but it has this on the end:
+ listings[i].uri +


example:

http://www.website.com/links/+ listings[i].uri +


In IE 6.0, it cames up as a syntax error when loading the page. I have the option enabled to display notification of every script error.

Hope this helps.

Michael

michael26
01-29-2003, 11:06 PM
Dave...

You did it! Thank you for all your help! I finally figured it out!

You are the best!

Thanks again!

Michael

:) :) :) :) :) :)