POP UP with image

N

News

Hi

I am trying to create a new window with a image in it. I cannot seem to get
the image working please point out my error.


http://www.wyght.com/warren/Warren/MySite/TamaraRing.html

code below

<script language="javascript1.5">

function OpenWindow()
{
var tY=(this.screen.width)*.9;
var tX=(this.screen.height)*.9;

window.sText="<BODY><img src='TamarasRing\\Sliced\\005_5_r2_c2.jpg'
/></BODY>";

window.open("javascript:eek:pener.sText","SecWin",",width=tY,height=tX").focus();}</script></head><body><BR /><img src="TamarasRing/Sliced/005_5_r2_c2.jpg" width="156" height="163"onclick="OpenWindow()"/><BR />Click on image!<BR />--Totus possum, totum Deum.Totus ero, totum meum.WSW
 
R

Randy Webb

News said the following on 3/2/2006 3:15 PM:
Hi

I am trying to create a new window with a image in it. I cannot seem to get
the image working please point out my error.

Which ones? There are so many.....

<script type="text/javascript">

That line right there is your problem. Well, the main problem.
And it's yet another reason *not* to use the language attribute.
 
J

Janwillem Borleffs

News said:
I am trying to create a new window with a image in it. I cannot seem
to get the image working please point out my error. [...]
<script language="javascript1.5">

This will cause the script to be ignored by IE6, which doesn't support this
version; use the following instead:

function OpenWindow()
{
var tY=(this.screen.width)*.9;
var tX=(this.screen.height)*.9;

You don't have to reference "this" here, when omitted, the window object is
assumed.
window.sText="<BODY><img src='TamarasRing\\Sliced\\005_5_r2_c2.jpg'
/></BODY>";

Do not use Windows style path seperators, but always forward slashes (unix
style)
window.open("javascript:eek:pener.sText","SecWin",",width=tY,height=tX").focus();}</script></head><body><BR

The window properties string is malformed; the preceding comma should be
removed and the tY and tX variables should be concatenated with the +
operator, as in: "width=" + tY + ",height=" + tX

Consider the following simplification:

<script type="text/javascript">
function OpenWindow(img) {
var tY = screen.width * .9;
var tX = screen.height * .9;
window.open(img.src,"SecWin","width=" + tY + ",height=" +
tX).focus();
}
</script>
....
<img src="TamarasRing/Sliced/005_5_r2_c2.jpg" width="156" height="163"
onclick="OpenWindow(this)" />


JW
 
N

News

Janwillem Borleffs said:
News said:
I am trying to create a new window with a image in it. I cannot seem
to get the image working please point out my error. [...]
<script language="javascript1.5">

This will cause the script to be ignored by IE6, which doesn't support
this version; use the following instead:

function OpenWindow()
{
var tY=(this.screen.width)*.9;
var tX=(this.screen.height)*.9;

You don't have to reference "this" here, when omitted, the window object
is assumed.
window.sText="<BODY><img src='TamarasRing\\Sliced\\005_5_r2_c2.jpg'
/></BODY>";

Do not use Windows style path seperators, but always forward slashes (unix
style)
window.open("javascript:eek:pener.sText","SecWin",",width=tY,height=tX").focus();}</script></head><body><BR

The window properties string is malformed; the preceding comma should be
removed and the tY and tX variables should be concatenated with the +
operator, as in: "width=" + tY + ",height=" + tX

Consider the following simplification:

<script type="text/javascript">
function OpenWindow(img) {
var tY = screen.width * .9;
var tX = screen.height * .9;
window.open(img.src,"SecWin","width=" + tY + ",height=" +
tX).focus();
}
</script>
...
<img src="TamarasRing/Sliced/005_5_r2_c2.jpg" width="156" height="163"
onclick="OpenWindow(this)" />


JW
THANKS
 
N

News

Randy Webb said:
News said the following on 3/2/2006 3:15 PM:

Which ones? There are so many.....


<script type="text/javascript">

That line right there is your problem. Well, the main problem.
And it's yet another reason *not* to use the language attribute.

What is incorrect about language="java....
 
R

Randy Webb

News said the following on 3/2/2006 5:08 PM:
What is incorrect about language="java....

If you take your old page, as is, with the language attribute and change
it to type="text/javascript" then your popup window starts working.

That alone should tell you one of the things wrong with it. The major
problems with it? In any modern doctype the language attribute is
deprecated and the type attribute is required. But, that is semantical.

Problems with language attribute is that most people who want to use it
don't understand the ramifications of doing so. In your case IE doesn't
support javascript1.5 so it ignored the script block.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,052
Members
48,769
Latest member
Clifft

Latest Threads

Top