NationStates Jolt Archive


javascript foibles [help]

Pure Metal
22-12-2006, 20:05
ok, i occasionally post html and other web-designing problems on here, but i do try to keep them to a minimum when i really can't find the answer anywhere else on the ol' web :)

i have a teeny question for anyone who can help (milk and cookies, and a nice dollop of nice person-ness to all who do :fluffle: )

a site of mine uses a clever little script to resize the height of the index page according to the height of the page being loaded into one of the index page's iframes (used for displaying main content). its great, but it only works in IE.
this isn't much of a problem except that to make the pages viewable by other browsers i must add a 'failsafe' height for the iframe which totally negates the point of having the script above in the first place :(

so what i've decided to do is to have the user to come into an index with said scipt set up for IE (as to not make IE users load two pages), then a script determine the user's browser, and if its not IE send them to an index with said failsafe height for the main content iframe.
if it is IE then it should do nothing and stay on the page loaded. here is the problem.



the script is:

<SCRIPT LANGUAGE="JavaScript">

var name = navigator.appName
if (name == "Microsoft Internet Explorer")
url=("STAY ON THIS PAGE");
else
url=("GO TO NON-IE INDEX")
window.location=url;

</SCRIPT>



so its that "stay on the same page" bit in red i'm having trouble with. i just need a null value in there or something.... i've tried self, null, none, blank.htm... all sorts, but they all treat it like a url and i just want it to stay on the same damn page :mad:

the other bit in red works just fine and sends non-IE browsers to a page with the failsafe iframe height :)



any help?
ConscribedComradeship
22-12-2006, 20:17
ok, i occasionally post html and other web-designing problems on here, but i do try to keep them to a minimum when i really can't find the answer anywhere else on the ol' web :)

i have a teeny question for anyone who can help (milk and cookies, and a nice dollop of nice person-ness to all who do :fluffle: )

a site of mine uses a clever little script to resize the height of the index page according to the height of the page being loaded into one of the index page's iframes (used for displaying main content). its great, but it only works in IE.
this isn't much of a problem except that to make the pages viewable by other browsers i must add a 'failsafe' height for the iframe which totally negates the point of having the script above in the first place :(

so what i've decided to do is to have the user to come into an index with said scipt set up for IE (as to not make IE users load two pages), then a script determine the user's browser, and if its not IE send them to an index with said failsafe height for the main content iframe.
if it is IE then it should do nothing and stay on the page loaded. here is the problem.



the script is:




so its that "stay on the same page" bit in red i'm having trouble with. i just need a null value in there or something.... i've tried self, null, none, blank.htm... all sorts, but they all treat it like a url and i just want it to stay on the same damn page :mad:

the other bit in red works just fine and sends non-IE browsers to a page with the failsafe iframe height :)



any help?

Put the link of the page they are on? =\
Pure Metal
22-12-2006, 21:04
Put the link of the page they are on? =\

nope... tried that... just makes a horrific self-recurring thing where it just keeps loading the same page indefinately :p
ConscribedComradeship
22-12-2006, 21:05
nope... tried that... just makes a horrific self-recurring thing where it just keeps loading the same page indefinately :p

Can't you add another line making it only work once? :S
Ginnoria
22-12-2006, 21:07
Have you tried:

<SCRIPT LANGUAGE="JavaScript">

var name = navigator.appName
if (name != "Microsoft Internet Explorer")
{
window.location=("GO TO NON-IE INDEX");
}

</SCRIPT>

?
Pure Metal
22-12-2006, 21:09
Can't you add another line making it only work once? :S

yeah that'd work, maybe. but:
a) how? (i'm not hot on javascript)
b) it couldn't run once if it sends the browser to the same page, as as soon as the second instance of the page is loaded it'd just run again without any knowledge that its just been run.... it'd probably need some external js file to do that :confused:
ConscribedComradeship
22-12-2006, 21:10
(i'm not hot on javascript)

Ah, nor am I. :p
Iztatepopotla
22-12-2006, 21:12
so its that "stay on the same page" bit in red i'm having trouble with. i just need a null value in there or something.... i've tried self, null, none, blank.htm... all sorts, but they all treat it like a url and i just want it to stay on the same damn page :mad:

the other bit in red works just fine and sends non-IE browsers to a page with the failsafe iframe height :)

any help?

You are overthinking the problem. Simply do

if (name != "Microsoft Internet Explorer") {
window.location=url;
}

and that's it.

However, you may want to change your javascript script to use innerHeight if the browser is not IE to make the resizing compatible with Firefox and other browsers as well as IE.
Pure Metal
22-12-2006, 21:19
Have you tried:



?

that's the ticket!! thank you :):) :fluffle: :fluffle: :fluffle:

it works except for a little niggle in FF, but i shall fix it :)
Ginnoria
22-12-2006, 21:19
that's the ticket!! thank you :):) :fluffle: :fluffle: :fluffle:

it works except for a little niggle in FF, but i shall fix it :)

Yays ^_^ :fluffle:

*eats cookies and milk*
Sumamba Buwhan
22-12-2006, 21:58
I m ay be late

why have an else?

just say if NOT EQUAL (!= right?) to IE then...
Sumamba Buwhan
22-12-2006, 21:59
yep I'm late - damn me to hell!
Johnny B Goode
22-12-2006, 22:43
ok, i occasionally post html and other web-designing problems on here, but i do try to keep them to a minimum when i really can't find the answer anywhere else on the ol' web :)

i have a teeny question for anyone who can help (milk and cookies, and a nice dollop of nice person-ness to all who do :fluffle: )

a site of mine uses a clever little script to resize the height of the index page according to the height of the page being loaded into one of the index page's iframes (used for displaying main content). its great, but it only works in IE.
this isn't much of a problem except that to make the pages viewable by other browsers i must add a 'failsafe' height for the iframe which totally negates the point of having the script above in the first place :(

so what i've decided to do is to have the user to come into an index with said scipt set up for IE (as to not make IE users load two pages), then a script determine the user's browser, and if its not IE send them to an index with said failsafe height for the main content iframe.
if it is IE then it should do nothing and stay on the page loaded. here is the problem.



the script is:




so its that "stay on the same page" bit in red i'm having trouble with. i just need a null value in there or something.... i've tried self, null, none, blank.htm... all sorts, but they all treat it like a url and i just want it to stay on the same damn page :mad:

the other bit in red works just fine and sends non-IE browsers to a page with the failsafe iframe height :)



any help?

Just do this:

<script>
if (name != "Microsoft Internet Explorer") {
window.location = "GO TO NON-IE PAGE";
}
</script>
Pure Metal
23-12-2006, 00:04
i didn't know enough jscript (or maybe maths) to know != means "is not" :(


thanks for your help y'all :) :)