JS in php help

Hi everyone,

I really need some help, I’m sure the answer is simple but I can’t figure it out.

I have this js popup in my index.php :

<script language="javascript"> window.open('popup.html','','width=650,height=530') </script>

But I would like this to appear only on the home page, it is of course appearing on every page:

index.php?level=emptysuites_top1_content&pageid=7

etc etc.

Is there anyone who could tell me what I need to add or change so that the popup only appears on the home page?

Thanks!

Matthew. :slight_smile:

It seems like to me, it is posted on each html page, what you want to do, is go into every page and remove that script line, except for the index page.

If it is a template you can do something like this:

Thanks albertle5,

I have only added it to the index.php page, no other html pages or anything.

I tried to use that script you added but got no result from it unfortunately, anyone have any other ideas?

Thanks.

Well, Mattsbi, you showed us one line of JS… What calls this Javascript? Is it on each page? Is it part of an include that is on every page? Is it actually inside some PHP code as your title of your post says?

We are sure we can sort it out, but, we need to know how this small one line is called. Especially if it is actually called from PHP code… Help us help you!

Hi,

Mattsbi, the index.php probably gets run for every page, so it puts it on every page sent to the client. Looks to me like you want to make it conditional in index.php.

In psuedo-code:
if( the homepage is requested )
{ echo "<script language=“javascript”>window.open(‘popup.html’,’’,‘width=650,height=530’) ";
}
or remove it from index.php and put it in the php file that is used to build the home page.

To: ErnieAlex, he posted this in the “Learning PHP” section, give him a break and don’t waste our time with your crazy posts! They are okay for experienced people like me, but, for learners and beginners you are wasting everyone’s time!

Sponsor our Newsletter | Privacy Policy | Terms of Service