...

View Full Version : Would like index page to redirect viewer.



hothousegraphix
09-25-2003, 09:15 PM
I'm interested in having the index page to my site automatically redirect viewers to a tooless popup in which the site will appear.
At the same time I'd like the index page to jump to another "closing" or "thank you" page for lack of a better discription. I have the following script for a pop up which I have used in the past. I realize that it needs to go in a blank html doc.
I'm lost after that.


<script>
<!--
function winopen(){
var targeturl="newPage.html"
newwin=window.open("","","scrollbars")
if (document.all){
newwin.moveTo(0,0)
newwin.resizeTo(screen.width,screen.height)
}
newwin.location=targeturl
}
//-->
</script>


How do I go about getting the function to perform automatically?

Thanks!

lavalamp
09-25-2003, 09:26 PM
To get it to run the function automatically you would use the onload event handler, like this:

<body onload="winopen();">

I would suggest making your index page into the thank-you or good-bye page and including the pop-up script in it. Gimme 5 mins and I'll post an example of what I mean.

hothousegraphix
09-25-2003, 09:33 PM
I appreciate the assistance!!!

lavalamp
09-25-2003, 10:05 PM
OK, I made two different versions of the script. I suggest using the second version as it is more friendly for the people without JavaScript enabled.

hothousegraphix
09-25-2003, 10:45 PM
Ok, I have a few questions about 'version2'.

I'm seeing 3 pages (index, index2, & index3). When viewing the source to index.html I'm seeing a number of error messages (based on whatever situation arises), though I don't see the winOpen function, nor do I see any links to the two other pages.
When I click on that page nothing happens.

When I click on index2.html I get the fullscreen pop-up toolless window, while a smaller window appears, then disappears (I assume this is the "Goodbye" page). When I view source to index2 I see the same script I view in index.html.

Index3.html is self explanatory.

I'm confused as to how to link all three (because I see no reference to index2 or index3 in index.html. And, because nothing occurs when I click on index.html I'm not sure if this is actually what you've intended to be the index page? :confused:

I do appreciate your help!!!:)

BTW, I have it working using the suggested setup in your version 1.

lavalamp
09-25-2003, 10:54 PM
What's supposed to happen is when you open index.html, if you have JavaScript enabled it will re-direct you to index2.html.
If you don't have JavaScript enabled you will stay on index.html where it will display a noscript version of your web-site.

If you are re-directed to index2.html, it displays the good-bye message and opens index3.html as a new window with the JavaScript version of your web-site in it.

At least that's the way it's supposed to work. Could you explain in a lot more detail about exactly what happens when you open index.html and include what errors you are getting. Also whether you are using Mac or windows (I only have windows), and what browser and version etc. In the mean time I'll test out the script with all of the other browsers that I have.

hothousegraphix
09-25-2003, 11:13 PM
When clicking on index.html I'm getting the The page cannot be displayed message.

I'm on a windows machine, with XP. IE6 with latest updates.

As I said earlier I do have this working using the simpler version.

What I'm intending, is to have the index page redirect to a new window containing my flash site Link (http://www.hothousegraphix.com/ClientAccess/HHGV3/V3.html).
I've done this plenty of times with the on(click) function, though, never automatically.

lavalamp
09-25-2003, 11:52 PM
Hmmm, that's strange. I'm testing it in IE6 on Win XP home, complete with updates as well.

Have you disabled pop-ups or anything like that with your security settings? If so that could be causing the problem.

In any case I have replace location.href with location.replace, see if that solves the problem. If not try the file Copy of index.html and see if that one works, it will take you to the W3C site (theoretically).

Is it even the redirect that's the problem? Are you actually being taken to index2.html or are you being left at the index page?

hothousegraphix
09-26-2003, 12:18 AM
Being left on the index page. Haven't disabled anything.

I'll take a look at your updated version.

hothousegraphix
09-26-2003, 12:26 AM
Still occuring.

Though, when I click on index2.html, the pop-up occurs as intended, and when closed, index3 is displayed.

:confused:

Seems like the way it should work, but, from the index page, NOT index2.

cheesebag
09-26-2003, 12:33 AM
http://www.flashkit.com/tutorials/Tips_And_Techniques/Pop_up_s-shockwav-669/index.php

hothousegraphix
09-26-2003, 12:50 AM
cheesebag - thanks for the link, though, thats not exactally what I'm doing. I want the tooless pop-up window to open autimatically when the user types in the address and hits go on their browser, not with a button action.

I now understand how to have this function performed without
the user action.

Thanks

cheesebag
09-26-2003, 12:56 AM
hothousegraphix...

Figured that, but it's easy to modify, and seems a typical scenario for Flashers. Nice site, btw.

hothousegraphix
09-26-2003, 01:13 AM
Thanks:)

hothousegraphix
09-26-2003, 03:45 AM
K, here's a new wrinkle...I would also like to include this plug-in detection script I've found which gets placed in the same directory as the index page.
Below is the script provided:


<script src="plugins.js">

//Detect Plugin (Flash, Java, RealPlayer etc) //
//SAMPLE USAGE- detect "Flash"
if (pluginlist.indexOf("Flash")!=-1)
document.write("You have flash installed")

</script>


What I would like to do is something like this:


if (pluginlist.indexOf("Flash")!=-1){
//instead of document.write("You have flash installed")//
//I would like simply like to perform the winopen function//
//taking the user to the toolless pop-up if FLASH is installed//

winopen();
}
else{
//If user does not have FLASH installed - prompt to install//
window.location.href= "DownloadFLASHPLAYERpage.html"
}


What I need to know is if, for this to function correctly, should I place between the body tags and again use the onload function?

Does the above script look formatted correctly?

Thanks.

hothousegraphix
09-26-2003, 12:48 PM
^^^Any thoughts on my last post?^^^

glenngv
09-26-2003, 02:48 PM
Both will work but since the current page will be redirected to the DownloadFLASHPLAYERpage.html if no Flash is installed, you can just put the script inside the head tag. Why wait for the current page to load when you would redirect the user if no Flash is installed? and if there's a Flash, a new window is opened.
Hope that makes sense.

hothousegraphix
09-26-2003, 03:49 PM
That makes sense. Though, what I was intending for the index page was to place the prevebial "THANKS FOR VISITING" message which would appear as soon as the user closes the pop-up containing the actual site. I f I do as you suggest, how would I get that page loaded into the primary browser window if it's not included as part of the index page?

One other question, am I correct that everything I've suggested should go in the onload function to have it occur automatically?

I hope I've been clear.

Thanks

lavalamp
09-26-2003, 03:59 PM
It doesn't have to go in the onload event handler. You could just run all of the functions in your script, like this:

function_1();
function_2();
function_3();

//--></script>

</head>

Or, in the onload:

<body onload="function_1();function_2();function_3();">

If you want them to occur as soon as possible put them at the end of the script in the head section, otherwise run them onload (recommended).

hothousegraphix
09-26-2003, 04:47 PM
Great, I'll give it a go, then let you know!!!

Thanks:)

lavalamp
09-27-2003, 12:34 AM
I'm happy to be of assistance again, it seems like you've been busy since I last checked in.

I still don't understand why such a simple script, with only one location.href, didn't work though.

hothousegraphix
09-27-2003, 03:31 AM
Seems like I've got everything working.

This is what I've got, could you take a peak and let me know if you see anything out of the ordinary; anything I might want to change or correct?


<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>FLASH detection page</title>
<script>
<!--
function winopen(){
var targeturl="V3.html"
newwin=window.open("","","scrollbars")
if (document.all){
newwin.moveTo(0,0)
newwin.resizeTo(screen.width,screen.height)
}
newwin.location=targeturl
}
//-->
</script>
<script src="plugins.js"></script>
</head>

<body bgcolor="#ffffff">
<!--webbot bot="HTMLMarkup" startspan --><script>
if (pluginlist.indexOf("Flash")!=-1)
winopen();
else
document.write("Your browser does <b>NOT</b> support flash!")
</script><!--webbot bot="HTMLMarkup" endspan -->
</body>

</html>


As I said earlier, this is actually working.

lavalamp
09-27-2003, 02:16 PM
<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>FLASH detection page</title>
<script type="text/javascript">
<!--
function winopen(){
var targeturl="V3.html"
newwin=window.open(targeturl,"","scrollbars")
if (document.all){
newwin.moveTo(0,0)
newwin.resizeTo(screen.width,screen.height)
}
}
//-->
</script>
<script type="text/javascript" src="plugins.js"></script>
</head>

<body bgcolor="#ffffff">
<!--webbot bot="HTMLMarkup" startspan --><script type="text/javascript"><!--
if (pluginlist.indexOf("Flash")!=-1)
winopen();
else
document.write("Your browser does <b>NOT</b> support flash!")
//--></script><!--webbot bot="HTMLMarkup" endspan -->
</body>

</html>


Only a couple of minor changes, otherwise it's fine.

hothousegraphix
09-27-2003, 04:04 PM
Thanks,

Another question...if you don't mind.

Keeping in mind the script above, how would I (after the "winopen" function is performed) send the main browser window to a new url (occuring under the pop-up so the user is
unaware of this switch)?

I hope that makes sense.

Would I simply add this to the "winopen" function:


window.location.href= "NewDocInMainBrowserWindow.html"


Thanks again.

glenngv
09-27-2003, 04:46 PM
function winopen(){
var newwin=window.open("V3.html","","scrollbars");
newwin.focus();
location.href= "NewDocInMainBrowserWindow.html";
...

lavalamp
09-27-2003, 05:42 PM
At one point I gave you a script with a single location.href in that didn't work, I don't know why the above script will be any different. If it does work then that's another one lifes little confusing things.

If you want you could use location.replace("http://www.w3.org/"); this means that when the user presses back, rather than being taken to your index page they are taken to the page before that.

hothousegraphix
09-28-2003, 08:24 PM
:) GOT everything working as it should.

One more question: If with the winopen function I want to open a window that isn't fullscreen - lets say it's 100px x 100px - and I want to have that window centered in the screen?


How would I alter the script below to achieve:


<script type="text/javascript">
<!--
function winopen(){
var targeturl="V3.html"
newwin=window.open(targeturl,"","scrollbars")
location.href= "IndexThankYou.html";
if (document.all){
//How do I get the window centered regardless of the window size
(I don't want to alway have to do the math).
If I use (screen.width/2,screen.height/2)
the upper left corner (ponit 0,0) of the window
will align with the center of the screen -
not what I want. //

newwin.moveTo(0,0)
newwin.resizeTo(100,100)
}
}
//-->
</script>


Hope this makes sense!

Thanks Much!!!

lavalamp
09-28-2003, 09:48 PM
As far as I know, you can't, you need to know the width and height then do this (for 100 x 100):

newwin.moveTo((screen.width/2)-50,(screen.height/2)-50)

liorean
09-28-2003, 09:54 PM
Use screen.availHeight and screen.availWidth instead of screen.width and screen.height, and add screen.availTop to the height and screen.availLeft to the width.

lavalamp
09-28-2003, 10:33 PM
Just goes to show what I know.

hothousegraphix
09-28-2003, 10:41 PM
Thanks for the info.

Something else I just noticed. If I alter the target url to something other that a page in my local directory; i.e.


targeturl="http://www.anotherWebsite.com"

The winopen function does not exicute fully.

Any ideas why this might be?

Performing it:


ONCLICK="winopen();"

liorean
09-28-2003, 10:43 PM
Yes. JavaScript is not allowed to reach across different domains, in the same way cookies are not allowed to be read from other domains. It's for privacy/security reasons. It can be mildly irritating sometimes, however.

hothousegraphix
09-28-2003, 11:02 PM
Would you have a suggestion for opening a new window with containing another domain?

lavalamp
09-28-2003, 11:19 PM
Sure, open one of your winows that has a built in re-direct script in.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum