Calling Javascript - Window.open in PHP -
i'm trying call window.open() javascript code inside php file, unfortunately not responding.
here's code:
<html> <head> <script language="javascript"></script> </head> <body> <?php ..... $printheader .= " <div id ='subheader'><p class = 'alignleft'><font style='color:blue'>user: " . $username . " | access: " . $level ." | <a href=logout.php>logout</a></font></p>"; $printheader .= " <p class='alignright'><a href='refresh.php' onclick='window.open(this.href,'mywin','width=400,height=200')'>refresh list</a></p></div>"; $printheader .= "<div style='clear: both;'></div>"; .... ?> </body> </html>
unfortunately, when run it, doesn't work @ all. can not call javascript in php? please advise!
thanks!
i think issue related quotes, inner single quotes ending onclick string, replacing outter single quotes double quotes(will keeping inner quotes single) solve issue. try changing this:
onclick='window.open(this.href,'mywin','width=400,height=200)'
to this:
onclick=\"window.open(this.href,'mywin','width=400,height=200)\"
here's example:
another solution escape inner quotes prefixing them backslash (\
).
Comments
Post a Comment