Jump to content

[SOLVED] how to make a popup


Lodius2000

Recommended Posts

hi there all, I am trying to make a good ol popup, that is multibrowser, especially firefox compatible, ie target blank doesnt work becuase it forces it into a tab, plus i want this new window to be smaller than a full maximized browser window because it is basically a widget on my page that you dont need once it has done its duty, so i have a close window button that works

 

i tried this

page 1 linked to the widget page via target="_blank" and the wiget page contained the follow js in the <head>

<script>
window.resizeTo(500, 500);
</script>

that opened a new tab and then resized all the tabs to 500 by 500

 

so i found this code on the intartubes that i put into a print statement on page 1 from above, but i dont know anything about js

<?php
print '<a href="../imageupload/index.php" onclick="window.open(\'../imageupload/index.php','popup','width=500,height=500,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0\'); return false\'>Upload photo</a>';
?>

php gives me a parse error saying im missing a comma (,) somewhere in this line, i dunno where to start, or even if this will work. I do like the non resizable, non scroll, non toolbar approach

 

I just want it to be a new window with no tools or bars 500 by 500 that displays my php

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/113286-solved-how-to-make-a-popup/
Share on other sites

well it look slike your somehow ending your string halfway through:

 

'<a href="../imageupload/index.php" onclick="window.open(\'

 

I dont use print, however that will be interpreted as onestring will it not.  therefore your missing comma should bethe character after that.

 

gdlk

pc nerd

 

the \ is an escape character so that ' means literally ' not "end string here"

notice that the entire string is the same color in the code, meaning it is all 1 string, that is as long as this code interpreter is correct

 

Actually you have only one un-escape delimiter on the string and you have the series of ' (single quotes) if you look at the color coding the comma's in the string are green

 

<?php
print '<a href="../imageupload/index.php" onclick="window.open(\'../imageupload/index.php\',\'popup\',\'width=500,height=500,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0\'); return false;\">Upload photo</a>';
?>

Try that :)

Darkwater

 

cant believe i didnt see that thanks,

 

//note, I added a target="_blank" in there because the link was opening in the same window

 

but

 

the redone code still just opens a new tab in firefox, no resize

 

in safari it opens a new window but there is no resize either

 

code now looks like

 

<?php
print '<a href="../imageupload/index.php" target="_blank" onclick="window.open(\'../imageupload/index.php\',\'popup\',\'width=500,height=500,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0\'); return false;\">Upload photo</a>';
?>

<?php
print '<a href="javascript:void();" onclick="window.open(\'../imageupload/index.php\',\'popup\',\'width=500,height=500,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0\');\">Upload photo</a>';
?>

 

Okay try that, the first post I was just trying to help you fix your code.

 

I think the way you have it will try to open up the URL cause you have it in a HREF you might want to try echoing a function for it to use (JScript)

 

But try that first.

this is the exact code I have running on my site (converted to PHP output and to accommodate your usage)

 

<?php
echo("<script type=\"text/javascript\">\nfunction uploadwindow() {
new_window = window.open('../imageupload/index.php','popup','width=500,height=500,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');
}
</script>
<a href=\"javascript:uploadwindow();\">Upload Photo</a>");
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.