Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document.write issues 1

Status
Not open for further replies.

Aztech1

Technical User
Mar 1, 2009
33
LV
the "ALT" text is not shown when mouseover image:
[tt]newWindow.document.write('<img src="'+imageName+'" width='+imageWidth+' height='+imageHeight+' alt="Click to close" >');[/tt]

Is it possible add "title" attribute to show text on mouseover? i.e.
[tt]
newWindow.document.write('<img src="'+imageName+'" width='+imageWidth+' height='+imageHeight+' title="Click to close" alt="Click to close" >');[/tt]
Code:
{
	newWindow = window.open("vwd_justso.htm","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+' onBlur="self.close()" onClick="self.close()">');  
	newWindow.document.write('<table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td>');
	newWindow.document.write('<img src="'+imageName+'" width='+imageWidth+' height='+imageHeight+' alt="Click screen to close" >'); 
	newWindow.document.write('</td></tr></table></body></html>');
	newWindow.document.close();
	newWindow.focus();
	}
also, how to add loading.gif to show it when image loads?
 
could be because the newwindow in not in focus - if it is not in focus then the alt tag won't work, or it could be because you need to set all your attributes the same way - you need double quotes around your width / height.

This works for me:

Code:
document.write('<img src="'+imageName+'" width=[COLOR=red]"[/color]'+imageWidth+'[COLOR=red]"[/color] height=[COLOR=red]"[/color]'+imageHeight+'[COLOR=red]"[/color] alt="Click to close" title="Click to close" >');

TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
It works now in Firefox and IE both(it not worked in Firefox).
Not sure, do we really need double quotes around width / height? It works without double quotes also.
 
You should keep everything the same - use quotes on all attributes (single or double, but keep it consistant).



TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
thanks for tip. Some ideas how to add loading.gif to show it when image loads?
 
^ what exactly do you mean by "add loading.gif"?



TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
^ I can't view that link from work - it's blocked (major lockdown here).

I'll take a look when I get home...

If what you want is to show an image while the other one is loading, something like this might work:

Code:
<img src="preload.gif" id="myImg" />
<script>
document.getElementById("myImg").src = "newImage.gif";
</script>

TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
yes, I just mean simple preloader. Which place this can be added?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top