Re: I don't get javascript. How do you use it?
- From: "Scott M." <s-mar@xxxxxxxxxxxxx>
- Date: Mon, 26 Mar 2007 12:46:58 -0400
z-index is the CSS property that controls layering of elements in a web
page. To use it within the realm of CSS, case doesn't matter (since CSS is
also not case-sensitive, like HTML) and it is used as: z-index (with the
hyphen).
When you want to access a CSS property from within a language like
JavaScript, then you must follow the case sensitivity of the language you
are in. JavaScript is case-sensitive (unlike CSS and HTML), so even if you
wish to affect some CSS, you would now have to use the correct case. Also,
in JavaScript (or more accurately, the Browser's Object Model or BOM) that
is accessed via JavaScript, the object properties that affect CSS don't
always match their CSS counterparts. For exapmle:
[Straight CSS inside a web page's HTML]
<!-- case does not matter in the following -->
<P ID="theText" STYLE="z-index:1">some text</P>
[JavaScript embedded within HTML]
<SCRIPT TYPE="text/JavaScript">
// case does matter in here because this area is JavaScript
theText.style.zIndex = 2;
</SCRIPT>
In short, when writing any kind of code, you must write it according to the
language that you are writing at the time.
If you really want to get a grasp of what your question encompasses, you'll
need to research the following:
-HTML
-CSS
-JavaScript
-The Document Object Model (standard OO API to a web document)
-The Browser Object Model (sometimes people confuse this with the Document
Object Model) (vendor specific OO API to browser and document)
-Scott
"Tony Girgenti" <tony(nospam)@lakesideos.com> wrote in message
news:uVcnf06bHHA.264@xxxxxxxxxxxxxxxxxxxxxxx
Hello Goran.
You obviously know a lot about javascript. How does a person figure
whether to use "z-index" or "zindex" or "zIndex" or "ZINDEX" or whatever.
Is that kind of stuff documented somewhere?
Thanks,
Tony
--
Any help would be gratefully appreciated.
Thanks,
Tony
"Göran Andersson" <guffa@xxxxxxxxx> wrote in message
news:%23q7SiYybHHA.4872@xxxxxxxxxxxxxxxxxxxxxxx
Tony Girgenti wrote:
Thanks to everyone for their replies.
I finally figured it out. There were several issues. One problem was
that i was using "onClick" with a capital "C" in the HTML button.
Another issue was i didn't need a ";" at the end of the onclick
statement, but i did need the "()".
I know that i probably confused everybody by showing different versions
of the code that i had, and i apologize for that. Both of the buttons
work now using the following function:
function ShowMsg()
{
alert(Calendar1.innerText);
myElement = document.getElementById("Calendar1");
alert(myElement.style.position);
}
With the HTML button i used "onclick="ShowMsg()" and with the ASP button
i used "onClientClick="ShowMsg()" . The Calendar1 displays then the
position property displays.
However, i still can't get the "z-index" or "zindex" to display. For
the "z-index" it gives an error on line 14, character 9 and for
"zindex", It just displays "undefined" in the alert. Line 14, character
9 is the "}" in my function.
That's because it's zIndex, not zindex. Look at the code in my previous
code.
Not that i would really ever want to display the z-index of any element
in a real situation, i'm just curious as to why it won't display.
I'm on my way now to practicing and learning more about javascript and i
really appreciate everybody's help in figuring this stuff out.
Thanks,
Tony
"Scott M." <s-mar@xxxxxxxxxxxxx> wrote in message
news:u$cwZ7lbHHA.2076@xxxxxxxxxxxxxxxxxxxxxxx
Or, in your page_load event, programmably add the client-side event
handler:
Button1.attributes.add("onclick","ShowCal()")
By the way, remember to include the parenthesis in your JavaScript
function call, as they are part of the function name (see above). Now,
as long as you do have a client-side JavaScript function called
ShowCal(), and it is coded correctly, clicking your button will invoke
the function.
-Scott
"Göran Andersson" <guffa@xxxxxxxxx> wrote in message
news:OWuzw7jbHHA.4656@xxxxxxxxxxxxxxxxxxxxxxx
Tony Girgenti wrote:
Hello.As Mark said, the OnClick event of a server control is a server event.
I just finished reading two articles about javascript here:
http://msdn2.microsoft.com/en-us/library/bb332123(VS.80).aspx
I tried some javascript testing in VS2005, SP1, VB , .NET 2.0,
ASP.NET 2.0 on WIN XP Pro, SP2.
It's real simple. I put a button on a page and coded the onClick in
it like this:
<asp:Button ID="Button1" runat="server" Style="z-index: 103; left:
528px; position: absolute; top: 392px" Text="Button"
OnClick="ShowCal" />
Here is the function:
<script type="text/javascript" language="javascript">
function ShowCal() {
var x = Button1.Style.z - index;
alert(x);
}
</script>
It won't let me run the program saying "'ShowCal' is not a member of
'ASP.default_aspx'"
If javascript is so popular, why can't i use it?
Any help would be gratefully appreciated.
Thanks,
Tony
Use the OnClientClick property to create a client side onclick event.
Or use an html element instead:
<input type="button" style="position: absolute; z-index: 103; left:
528px; top: 392px;" value="Button" onclick="ShowCal();" />
Notice that the onclick property contains the code to call the
function, not just the function name.
Some browsers expose the elements with an id as properties in the
document, but you should use the getElementById to access them to
write code that works in all (modern) browsers. Javascript is case
sensetive, so you have to write all names using the correct case.
<script type="text/javascript">
function ShowCal() {
var x = document.getElementById('Button1').style.zIndex;
alert(x);
}
</script>
--
Göran Andersson
_____
http://www.guffa.com
--
Göran Andersson
_____
http://www.guffa.com
.
- References:
- I don't get javascript. How do you use it?
- From: Tony Girgenti
- Re: I don't get javascript. How do you use it?
- From: Göran Andersson
- Re: I don't get javascript. How do you use it?
- From: Scott M.
- Re: I don't get javascript. How do you use it?
- From: Tony Girgenti
- Re: I don't get javascript. How do you use it?
- From: Göran Andersson
- Re: I don't get javascript. How do you use it?
- From: Tony Girgenti
- I don't get javascript. How do you use it?
- Prev by Date: Re: asp.net to 2.0
- Next by Date: Re: Ajax error: there was an error in the callback.376
- Previous by thread: Re: I don't get javascript. How do you use it?
- Next by thread: Re: I don't get javascript. How do you use it?
- Index(es):
Relevant Pages
|