Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open window is seen as a popup. Anyway around this?

Status
Not open for further replies.

Zych

IS-IT--Management
Apr 3, 2003
313
US
Hello All,

I have a simple page that has a form on it. At first I did it in javascript which is probably best but I am very new to javascript. Basically it took the info in the form and opened a window with the information.

I have now done this in PHP but to get the window to open with a javascript window.open I had to call it from the body with an onLoad event. So I got all the info with PHP and then opened the window with javascript. The problem is that by using it as a onLoad event the window is now considered a popup by my popup blocker. When it was called with the onsubmit function when I had it in javascript there was not a problem. Is there anyway around this?

- Zych
 
I don't really see there being a legit way around it as that would render pop-up blockers useless. My advice would be to go back to your previous way and use it as a way to learn javascript while getting something useful out of the end.
 
You don't need to use Javascrpt to create a form or read it.

Probably the easiest way is to create a PHP page that includes an HTML form, which submits information back to itself.

This page will first test for submitted variables, and if it finds that that the page has been requested by the client posting information, then it processes that information, and returns a 'thank you' page, or the like. If the page was requested without posting any variables, then the default form is presented to the user.

You will need to put in the form element's attributes something like:
...action="<?php __FILE__; ?>"... to tell the script to submit is back to itself. (The __FILE__ constant is one way of inserting the current file's name.)

You could use Javascript for checking some of the form's entries, before submitting the form. However, you should always have a PHP script that checks these values as well, since the client may not have Javascript installed or enabled (about 10% of internet browsers don't). This is important both for the integrity of the data that is processed (presumably to put into a database), and for security - since malicious code can compromise the security of a server.

I hope this helps.

Good luck!
 
If you want to keep the popup, put a notice on your site, saying something like:

"To properly view this web-page, you need to accept popups on this site"

I think that is a feasable way to do it, unless it's vital though.

Olav Alexander Mjelde
Admin & Webmaster
 
Thanks for the advice. I think I may try a hybrid approach. That is of course if I can use an onsubmit and a post in the same form. This may solve my problem. I am trying to make a page so I can view sites in different sizes. I have my screen set to 1280 x 1024 and when I design a page I want to see it in 800 x 600 and even 640 x 480, etc. I had it working with javascript but I wanted to add in some features with PHP. The form does submit to itself so you can then view another page or change the resolution.

- Zych
 
Since this is just you, i.e. for your own use, I'd configure the popup blocker to allow popups from your server.
 
It also allows me to learn some other things. I may publish so others that may need this can use it also. I know there may be another site out there that does this but I have only found one, and it was not funtioning at that time. At the same time I have not done a thorough search.

If it becomes of any use I a may add on a database so people can put links to other useful utilities that they have found. For example a little program called CatchColor has been useful to me. It puts an eyedroper in your system tray that can be used to find the color of anything you have on the screen. It is simple but saves me a lot of time in some situations.

- Zych
 

I always open new windows with
target="_blank"
because I prefer when it's the user who triggers the display of some new content.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top