...

View Full Version : Can someone take a look at this code for me



hecka
07-27-2006, 01:26 AM
Hi there,
I am a JS newbie and I am having trouble getting the following code to work within my IE6 Browser. It seems to work fine in Firefox, Opera, Netscape and Mozilla. I have checked the browser settings for Java script and have also disabled the popup blocker. Can anyone help?:confused:

<html>
<head>

<SCRIPT LANGUAGE="JavaScript">


function glossterm(term, desc)
{
var gen=window.open('','Cullinary Definition','width=400,height=100,status=no,scrollbars=no,resizable=yes,screenX=100,screenY=200,left =100,top=200');

gen.document.write('<html><head><title>Cullinary Definition</title>');
//gen.document.write('<link rel="stylesheet" href="style.css">');
gen.document.write('</head><body>');
gen.document.write('<p><strong>' + term + '</strong><br>');
gen.document.write('"'+ desc + '</p>');
gen.document.write('<p><a href="javascript:self.close()">Close</a> this window.</p>');
gen.document.write('</body></html>');
gen.document.close();
}

</script>

</head>

<body>

<a href="javascript:glossterm('Hollandaise Sauce','Basic egg and butter sauce.');">hollandaise</a>

</body>
</html>

Vladdy
07-27-2006, 01:40 AM
Sure you do not have some sort of popup blocker?

Kravvitz
07-27-2006, 01:45 AM
Why do you want to use window.open() just to display that small amount of information?

You might want to use one of these instead:
http://www.bosrup.com/web/overlib/
Tooltips, Floating captions - DHTML, javascript - BoxOver (http://boxover.swazz.org/)
DOM Tooltip (http://www.mojavelinux.com/cooker/demos/domTT/)
http://www.walterzorn.com/tooltip/tooltip_e.htm
http://kryogenix.org/code/browser/nicetitle/

Keep in mind that some Internet users use a browser that doesn't have JavaScript enabled. (http://www.thecounter.com/stats/2006/June/javas.php)

The Importance of Degrading Gracefully (http://weblog.burningbird.net/archives/2005/03/25/the-importance-of-degrading-gracefully/)
Perpetuating the myths of JavaScript degradation. (http://domscripting.com/blog/display.php/25)

hecka
07-27-2006, 02:27 AM
Thanks guys,
Maybe I should look at using a different technology. Although, I would like to get this one working as I hate to let bugs defeat me; Especially In such a simple piece of code!:thumbsup:

RexxCrow
07-27-2006, 03:03 AM
Is this any better for ya?


<html><head><SCRIPT LANGUAGE="JavaScript">
function glossterm(term, desc) {
gen='<html><head><title>Cullinary Definition</title></head><body><p><strong>' + term + '</strong><br>'+ desc + '</p><p><a href="javascript:self.close();">Close</a> this window.</p></body></html>'
nw=window.open("","CullinaryDefinition","width=400,height=100,status=no,scrollbars=no,resizable=yes,screenX=100,screenY=200,left=100,top=200");
nw.document.write(gen); nw.document.close();
}
</script></head><body>
<a href="javascript:glossterm('Hollandaise Sauce','Basic egg and butter sauce.');">hollandaise</a>
</body></html>

RexxCrow
07-27-2006, 03:16 AM
Actually you have this working from what I tested you just need to make the window's name as one word.



<html>
<head>

<SCRIPT LANGUAGE="JavaScript">


function glossterm(term, desc)
{
var gen=window.open('','CullinaryDefinition','width=400,height=100,status=no,scrollbars=no,resizable=yes ,screenX=100,screenY=200,left=100,top=200');

gen.document.write('<html><head><title>Cullinary Definition</title>');
//gen.document.write('<link rel="stylesheet" href="style.css">');
gen.document.write('</head><body>');
gen.document.write('<p><strong>' + term + '</strong><br>');
gen.document.write('"'+ desc + '</p>');
gen.document.write('<p><a href="javascript:self.close()">Close</a> this window.</p>');
gen.document.write('</body></html>');
gen.document.close();
}

</script>

</head>

<body>

<a href="javascript:glossterm('Hollandaise Sauce','Basic egg and butter sauce.');">hollandaise</a>

</body>
</html>

hecka
07-28-2006, 05:13 PM
Yeah,
Thanks mate, that worked a treat. I should have picked up on the fact that there can not be any spaces passed in the arguement.:o



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum