PDA

View Full Version : redirect script



bav1
08-10-2007, 03:14 AM
Hi all

im hoping you can help as this is starting to do my nut in

i am after a way of when people type in my domain name they get checked for flash

if they have the appropriate plugins installed they get redirected straight to index2.htm if not they goto a needflash.htm page with a download link or maybe auto install if thats possible heres where the problem is arising i want the redirect to open my website in a new window that is 1024 x 1024 that has just the scroll bar and is resizable

i would be extremely grateful if somone can just supply the code so i can just paste it directly into my index.html page

this is urgent and i have been trying to get my head around it for a few days now its propably somthing simple apologies if this is a stupid question but any help would be much appriciated

thanks in advance

jon

jscheuer1
08-10-2007, 06:37 AM
http://www.quirksmode.org/js/flash.html

bav1
08-10-2007, 09:04 AM
thanks john may be im being thick but i have been up all night trying to get this working but cant see where i configure if flash isnt installed goto needflash.htm if it is installed goto index2.htm

if you could alter the code that would be excellent thanks again

cheers jon

<SCRIPT LANGUAGE="Javascript">
<!--

var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";
if (navigator.plugins && navigator.plugins.length)
{
x = navigator.plugins["Shockwave Flash"];
if (x)
{
flashinstalled = 2;
if (x.description)
{
y = x.description;
flashversion = y.charAt(y.indexOf('.')-1);
}
}
else
flashinstalled = 1;
if (navigator.plugins["Shockwave Flash 2.0"])
{
flashinstalled = 2;
flashversion = 2;
}
}
else if (navigator.mimeTypes && navigator.mimeTypes.length)
{
x = navigator.mimeTypes['application/x-shockwave-flash'];
if (x && x.enabledPlugin)
flashinstalled = 2;
else
flashinstalled = 1;
}
else
MSDetect = "true";

// -->
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">

on error resume next

If MSDetect = "true" Then
For i = 2 to 6
If Not(IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & i))) Then

Else
flashinstalled = 2
flashversion = i
End If
Next
End If

If flashinstalled = 0 Then
flashinstalled = 1
End If

</SCRIPT>

jscheuer1
08-10-2007, 01:59 PM
Yep, you got it, that's almost all you need. One thing I noticed is that this was written around the time of Flash 6, so you need to change it in one spot:


If MSDetect = "true" Then
For i = 2 to 12
If Not(IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & i))) Then

Once that runs on your page you get two variables:


After the detect, the variable flashinstalled can have three values:

2: Flash installed
1: Flash not installed
0: Unknown if Flash is installed


The variable flashversion contains the version of Flash. If the version is unknown, it is 0.

In this page I document.write a little message based on the value of these two variables. You'll have to decide exactly what to do with the information this script provides, especially what to do if you don't know if Flash is installed.

So, now you need to decide what to do with those. You say you want to redirect to index2.htm or to needflash.htm (auto install is out of the question). There is a third possibility you haven't considered - failure of the script to detect anything or to not detect the version, leaving the question of whether the user has the Flash you require or not still open.

So, your detection page (index.htm) could look like so:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE="Javascript">
<!--

var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";
if (navigator.plugins && navigator.plugins.length)
{
x = navigator.plugins["Shockwave Flash"];
if (x)
{
flashinstalled = 2;
if (x.description)
{
y = x.description;
flashversion = y.charAt(y.indexOf('.')-1);
}
}
else
flashinstalled = 1;
if (navigator.plugins["Shockwave Flash 2.0"])
{
flashinstalled = 2;
flashversion = 2;
}
}
else if (navigator.mimeTypes && navigator.mimeTypes.length)
{
x = navigator.mimeTypes['application/x-shockwave-flash'];
if (x && x.enabledPlugin)
flashinstalled = 2;
else
flashinstalled = 1;
}
else
MSDetect = "true";

// -->
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">

on error resume next

If MSDetect = "true" Then
For i = 2 to 12
If Not(IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & i))) Then

Else
flashinstalled = 2
flashversion = i
End If
Next
End If

If flashinstalled = 0 Then
flashinstalled = 1
End If

</SCRIPT>
<script type="text/javascript">
if(flashinstalled==2&&flashversion>=8)
window.location.replace('index2.htm')
else if(flashinstalled&&flashversion)
window.location.replace('needflash.htm')
</script>
</head>
<body>
Flash detection Failed, choose:<br>
<a href="index2.htm">I have Flash 8 or better</a><br>or<br>
<a href="needflash.htm">I need Flash or an Upgrade</a>
</body>
</html>

Just make sure to edit these red parts so that they reflect the correct page locations and Flash version you are after:


<script type="text/javascript">
if(flashinstalled==2&&flashversion>=8)
window.location.replace('index2.htm')
else if(flashinstalled&&flashversion)
window.location.replace('needflash.htm')
</script>
</head>
<body>
Flash detection Failed, choose:<br>
<a href="index2.htm">I have Flash 8 or better</a><br>or<br>
<a href="needflash.htm">I need Flash or an Upgrade</a>

bav1
08-10-2007, 06:06 PM
thanks jon much appreciated that works a treat just one thing missing i want the index2 to open in a new window 1024x1024 with just scroll bar and that is resizable is this possible i suspect that i just need to edit the href at the bottom of the script any ideas

thanks again

jon

jscheuer1
08-11-2007, 05:02 AM
You cannot open a 1024 x 1024 window on a 1440 x 900 box like I'm running, let alone on a 800 x 600 screen, etc.

You cannot open a window (via javascript) with size specifications (essentially a pop up) in most browsers unless the user clicks on a link that does pretty much just that. In other words, you cannot launch a sized window from a Flash detection script.

Now, I'm no Flash expert, but I do know that Flash (at least some versions) can be made to occupy the entire content area of a window, while at the same time scaling itself to that area. How this is done, and what minimum version is required to do this, I do not know. But this is the direction you should go in.

Ask in the Flash forum here and/or in other Flash forums, or Google for information about this.