SitePoint Sponsor |
|
User Tag List
Results 1 to 16 of 16
Thread: Quick help!
-
Jun 6, 2002, 21:25 #1
Quick help!
Quick help please!
If you want some javascript to only occur if you're using IE (like 4+), how do you specify it?
I'd like to make it more than just IE4 but I don't know every single browser which supports the javascript command. It's field disabling and worked on IE but not NS.
-
Jun 6, 2002, 22:39 #2
- Join Date
- Aug 2001
- Location
- London
- Posts
- 2,475
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
what code have you got that you need to do this.
well by referencing an object you can do this
PHP Code:if (document.all) {}
else if (document.getelementByID){}
else (document.layer) {}
PHP Code:
<script type="text/javascript">
function blah(what, col)
{
what.style.backgroundColor=col;
}
</script>
<div onmouseover="blah(this, black)">blah</div>
-
Jun 6, 2002, 22:41 #3
lol what are you talking about?
I need the javascript only to occur if the user is using IE4+
It's a client-side form field disabling/enabling which doesn't work in NS and causes a problem.
-
Jun 6, 2002, 22:52 #4
- Join Date
- Aug 2001
- Location
- London
- Posts
- 2,475
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
well use this then
PHP Code:
if (document.all)
{
}
else if (document.getelementByID)
{
}
else (document.layer)
{
}
PHP Code:
if (navigator.appName == "Microsoft Internet Explorer")
{
//execute this chunk of code
}
PHP Code:
if (parseInt(navigator.appVersion) > 3)
{
} // end of Nav4+ only if
-
Jun 6, 2002, 22:55 #5
Thanks.
Last edited by geiger; Jun 6, 2002 at 22:58.
-
Jun 6, 2002, 23:04 #6
- Join Date
- Aug 2001
- Location
- London
- Posts
- 2,475
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
i can't remember what the codes supposed to be like for mozilla or opera
but just do this
PHP Code:alert(navigator.appName);
PHP Code:if (navigator.appName == "Microsoft Internet Explorer")
{
//execute this chunk of code
}
-
Jun 6, 2002, 23:05 #7
-
Jun 7, 2002, 05:59 #8
- Join Date
- Jan 2001
- Location
- Lawrence, Kansas
- Posts
- 2,066
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This field disabling script works in IE and Mozilla/NS6:
http://www.w3schools.com/dhtml/tryit..._input_disable
-
Jun 7, 2002, 11:03 #9
Odd... I'll talk to my scripter. Mine isn't! It gets stuck whichever way it starts out in NS/Mozilla.
-
Jun 7, 2002, 12:19 #10
If I want to have multiple enabled and disabled fields, how do I edit it? Also if I want to enable and disable checkboxes, etc. can I put "this"?
function makeDisable()
{
var x=document.this.name <-- does this work?
x[0].disabled=true
}
function makeEnable()
{
var x=document.this.name <-- does this work?
x[0].disabled=false
}
Do those work, and how do I add more than one?
-
Jun 7, 2002, 20:36 #11
-
Jun 7, 2002, 21:50 #12
- Join Date
- Aug 2001
- Location
- London
- Posts
- 2,475
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
as i said before use 'this' as a reference handle so it will work in any browser
PHP Code:
function makeDisable(what)
{
var x = what.name;
x[0].disabled = true;
}
function makeEnable(what)
{
var x = what.name;
x[0].disabled = false;
}
makeEnable(this) or makeDisable(this)
-
Jun 7, 2002, 21:53 #13Originally posted by Andrew-J2000
as i said before use 'this' as a reference handle so it will work in any browser
PHP Code:
function makeDisable(what)
{
var x = what.name;
x[0].disabled = true;
}
function makeEnable(what)
{
var x = what.name;
x[0].disabled = false;
}
makeEnable(this) or makeDisable(this)
So if I want a checkbox switched it would be
var x = select.viewable1;
var x = select.viewable2;
var x = select.viewable3;
and field
var x = field.description1;
?
-
Jun 7, 2002, 22:06 #14
- Join Date
- Aug 2001
- Location
- London
- Posts
- 2,475
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
erm, i'm not sure what you mean. Do you have the page online somewhere or can you post it form included
-
Jun 7, 2002, 22:07 #15
Yeah but its in a pass protected area. Do you have a real-time chat client?
-
Jun 7, 2002, 22:12 #16
- Join Date
- Aug 2001
- Location
- London
- Posts
- 2,475
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
yea check my signature 'Andrew-J', i'm not sure how much help i can be at the moment tho.
sobbering up still
Bookmarks