I am trying to open a new window in PHP by echoing what i need, because im placing information from my database in the URL.
I can get this to work in plain HTML, JS but as soon as i try and echo out the line it doesnt call the function, im sure im missing something obvious.
Got the code from here http://www.quirksmode.org/js/popup.html
Thanks
<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
newwindow=window.open(url,'name','height=400,width=600');
if (window.focus) {newwindow.focus()}
return false;
}
// -->
</script>
<?php
echo "<a href = 'popupex.html' onClick='return popitup(\'popupex.html\')'>234</a>";
?>
You had two hidden characters before your >
in )'>234
which could contribute to the problem. (Consult Footnotes).
Plus, I replaced (\'popupex.html\')
to (\"popupex.html\")
with escaped double quotes. Leaving them as single quotes did not make the window to pop up when testing.
The two hidden characters: ‌​
This works with both hidden characters removed. (tested)
Copy the code below, do not replace with what you already have.
<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
newwindow=window.open(url,'name','height=400,width=600');
if (window.focus) {newwindow.focus()}
return false;
}
// -->
</script>
<?php
echo "<a href = 'popupex.html' onClick='return popitup(\"popupex.html\")'>234</a>";
?>
Footnotes:
Leaving the hidden characters in the code would show up as this in the HTML source:
'??>234
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments