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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

code question

Status
Not open for further replies.

Aztech1

Technical User
Mar 1, 2009
33
LV
Just tried some code, noticed it does not work clean, want adjust a little, not sure does code required doctype <!DOCTYPE html PUBLIC...? also, what the sense use backslash in html tags?
Code:
function goImgWin(myImage,myWidth,myHeight,origLeft,origTop,capt) {
var mh = myHeight + 44;
var mw = myWidth + 24;
TheImgWin = window.open('','image','height=' + mh + ',width=' + mw + ',toolbar=no,directories=no,status=no,' + 'menubar=no,scrollbars=no,resizable=no');
TheImgWin.resizeTo(mw+2,mh+30);
TheImgWin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html[/URL] xmlns="http:\/\/[URL unfurl="true"]www.w3.org\/1999\/xhtml">');[/URL]
TheImgWin.document.write('<head><title>Popup<\/title><\/head>');
TheImgWin.document.write('<body style="overflow:hidden" bgcolor="#ffffff" onclick="self.close()">');
TheImgWin.document.write('<img src="'+myImage+'" width="'+myWidth+'" height="'+myHeight+'" ');
TheImgWin.document.write('border="0" alt="'+capt+'"\/><p align="center">'+capt+'<\/p>');
TheImgWin.document.write('<\/p><\/body><\/html>');
TheImgWin.moveTo(origLeft,origTop);
TheImgWin.focus();
}
 
Hi

Aztech1 said:
does code required doctype <!DOCTYPE html PUBLIC...?
[tt]DOCTYPE[/tt] is mandatory for all HTML documents.
Aztech1 said:
what the sense use backslash in html tags?
That is the XHTML syntax.
W3C said:
Empty elements must either have an end tag or the start tag must end with [tt]/>[/tt].
XHTML™ 1.0 The Extensible HyperText Markup Language (Second Edition) | Differences with HTML 4 | Empty Elements


Feherke.
 
I don't think doctype ans backslash ( \ ) need be used in javascript.
 
I don't think doctype ans backslash ( \ ) need be used in javascript.

The backslash is used as an escape character so you can do things like this:

Code:
var strLink = "<a href=\"[URL unfurl="true"]http://tek-tips.com\">Tek[/URL] Tips</a>";

If you want to include a backslash in your js, you need to escape it with one as well

Code:
var strText = "this is a backslash - \\";

if you are using single quotes, you may need to use it as follows:

Code:
var strText = 'this is Vic\'s post';



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
 
seems backslash must not be used in js code at all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top