Link to home
Start Free TrialLog in
Avatar of dklauk
dklauk

asked on

document.write syntax issue

I have a line of code inside a .js file that I have been messing with regarding the single and doulbe quotes and have not been able to resolve.  The idea here is to let the user click on the image and then a small window opens up.

Here is the code:

document.write('<a href=javascript:window.open("picture1details.asp",PageDescription,scrollbars="yes",menubar="no",toolbar="no",status="no",top="10",left="10",height="500",width="500",resizable="yes");return(false)><img src="picts/15242.jpg"  NAME="but" WIDTH="160" HEIGHT="83" BORDER="0" ALT="click to view details">/a>');

The click event occurs in the .asp that references the .js but the window does not open.  And, yes, the picture1details.asp is the right url.

Thanks.
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi dklauk,

document.write('<a href=javascript:window.open("picture1details.asp",PageDescription,"scrollbars=yes,menubar=no,toolbar=no,status=no,top=10,left=10,height=500,width=500,resizable=yes");return(false)><img src="picts/15242.jpg"  NAME="but" WIDTH="160" HEIGHT="83" BORDER="0" ALT="click to view details">/a>');


Tim Cottee
SOLUTION
Avatar of kumar_jac
kumar_jac
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
dklauk,

Actually, there are a few other things that need sorting as well as the incorrect parameters to the window.open call.

document.write('<a href="" onclick="javascript:window.open(&#39;picture1details.asp&#39;,&#39;PageDescription&#39;,&#39;scrollbars=yes,menubar=no,toolbar=no,status=no,top=10,left=10,height=500,width=500,resizable=yes&#39;);return(false);"><img src="picts/15242.jpg"  NAME="but" WIDTH="160" HEIGHT="83" BORDER="0" ALT="click to view details"></a>');

This solves the problem of the various quotes by using the encoded values for them. They will be rendered correctly to the page even though it does make it a little less readable perhaps.



Tim
Avatar of dklauk
dklauk

ASKER

Tim Cottee's last suggestion worked; kumar_jac's didn't--although I prefer this coding approach.

kumar_jac: any idea why your solution did not work?  
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dklauk

ASKER

TimCottee, your last suggestion does not work either.  However, it will work if I remove the 'argument' from the javascript:OpenDetails(argument) code and remove it from the .asp function OpenDetails(argument).  But, when I then run the .asp it does open a new window but then displays the text,  "false", in the parent browser window.


??