danman97 Posted September 13, 2011 Share Posted September 13, 2011 Hi I have continued a second page with a Popup Generator now (http://dl.dropbox.co...Untitled-2.html) but have come across a problem. I get no error but the link just won't open. Short Code: <!DOCTYPE html><head><script>/*Functions*/function editLink(){var lText= document.getElementById('linkText');var lURL= document.getElementById('linkURL');var lUL= lUL_value();var popH= document.getElementById('popH');var popW= document.getElementById('popW');var taValue= document.getElementById('taHTMLoutput');function lUL_value(){if (document.getElementById('uLine_yes').checked){ return "text-decoration:underline;";} else if (document.getElementById('uLine_no').checked){ return "text-decoration:none;";};};function changeHTML(){return "<a onClick="window.open("" + lURL.value + "","_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=" + popW.value + ", height=" + popH.value + "");" style="" + lUL + "">" + lText.value + "</a>";};taValue.value= changeHTML();document.getElementById('outputP').innerHTML= "<a onClick="window.open("" + lURL.value + "","_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=" + popW.value + ", height=" + popH.value + "");" style="" + lUL + "">" + lText.value + "</a>";}</script></head> <body><div id="uberContainer"><table width="100%"><tbody><tr><td><div id="mainContainer"><table align="center"><tr><td><form id="form1" onsubmit="return false;" style="border:1; border:#666"><legend><h3>Popup Details</h3></legend><div id="formContainer"><table><tr><td><label for="linkText">Link Text</label></td><td><input class="inputRight" id="linkText" autofocus="autofocus" placeholder="Mel Jones Photography Ltd." required size="40" type="text" autocomplete="on" /></td></tr> <tr><td><label for="linkURL">Link URL</label></td><td><input type="url" required class="inputRight" id="linkURL" placeholder="http://meljones.info/" autocomplete="on" size="40" /></td></tr><tr><td><label for="uLine">Underline</label></td><td><input id="uLine_yes" type="radio" name="uLine" value="yes" /> Yes <input id="uLine_no" type="radio" name="uLine" value="no" /> No</td></tr><tr><td><label for"linkCol">Colour</label></td><td><input id="linkCol" type="color" disabled /></td><tr><td><label for"popH">Height</label></td><td><input id="popH" placeholder="400" value="400" required type="number" /></td></tr><tr><td><label for"popW">Width</label></td><td><input id="popW" placeholder="600" value="600" required type="number" /></td></tr><tr><td></td><td><button onclick="editLink();">Amend Link!</button></tr></table></div></form></td><td><table><tr><td><h3>Output: </h3></td><td><p id="outputP"></p></td></tr><tr><td>HTML:</td><td><form id="formHTMLoutput"><textarea onClick="select_content('taHTMLoutput');" value="" id="taHTMLoutput"readonly placeholder="The HTML code for the Popup will appear here!"></textarea></form></td></tr></table></td></tr></table></div></td><td width="250px"></td></tr></tbody></table></div></body></html> Thanks Link to comment Share on other sites More sharing options...
Ingolme Posted September 13, 2011 Share Posted September 13, 2011 You've got a mess of quotes here: return "<a onClick="window.open("" + lURL.value + "","_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=" + popW.value + ", height=" + popH.value + "");" style="" + lUL + "">" + lText.value + "</a>"; And here: document.getElementById('outputP').innerHTML= "<a onClick="window.open("" + lURL.value + "","_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=" + popW.value + ", height=" + popH.value + "");" style="" + lUL + "">" + lText.value + "</a>"; Beyond that, I haven't given a deep look at your code. Those mistakes are enough to ruin a whole application. Link to comment Share on other sites More sharing options...
danman97 Posted September 13, 2011 Author Share Posted September 13, 2011 Do you mean how the '\' are missing. They dont seem to show on the forum but they are there on the web page. I just checked the Dev Tools and they are there... Or have you found another problem. I just cant find it! Link to comment Share on other sites More sharing options...
JamesB Posted September 13, 2011 Share Posted September 13, 2011 i think inside the onclick=" " you can't use " chars, or ' chars if your using onclick=' ', maybe there is a way to escape them but i'm not sure. try changing: onClick=\" to onClick=' and );\" style= to );' style= in both lines, so that the characters used to surround the onclick value are different from the characters used to surround the values sent to window.open() and used in style=. Link to comment Share on other sites More sharing options...
Ingolme Posted September 13, 2011 Share Posted September 13, 2011 A backslash won't escape a character in an HTML attribute. You should use " or use single-quotes instead of double-quotes. Link to comment Share on other sites More sharing options...
danman97 Posted September 14, 2011 Author Share Posted September 14, 2011 Thanks, working now! Swapped all but the " " around the onclick string. Link: http://dl.dropbox.co...Untitled-2.html Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.