473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Script for depressible buttons?

Is there a script for depressible buttons that work in Mozilla and IE?

This works nice but only in IE:
http://www.dynamicdrive.com/dynamici...ressbutton.htm.

Thanks,
Brett
Jul 23 '05 #1
9 1672
Brett wrote:
Is there a script for depressible buttons that work in Mozilla and IE?

This works nice but only in IE:
http://www.dynamicdrive.com/dynamici...ressbutton.htm.

Thanks,
Brett


"Easy to install and degrades well with all other browsers."

Rubbish, they don't work at all in Firefox. The effect is a "button"
that doesn't look like a button or a link, but if you click on it, off
you go to the new location. All that happens (in IE) is that the
borders are changed to simulate the "button" being depressed. The
author couldn't even write cross-browser JS to do it - what quality.

I'm sure someone here can do a better version in 10 minutes. Right now
I gotta do work...

Rob.
Jul 23 '05 #2
RobG wrote:
Brett wrote:
Is there a script for depressible buttons that work in Mozilla and IE?
[snip] I'm sure someone here can do a better version in 10 minutes. Right now
I gotta do work...


The functions are compatible with more browsers if the following:

function makeRaised(el) {
with (el.style) {
borderLeft = "1px solid buttonhighlight";
borderRight = "1px solid buttonshadow";
borderTop = "1px solid buttonhighlight";
borderBottom = "1px solid buttonshadow";
padding = "1px";
}
}

is rewritten as:

function makeRaised(el) {
el.style.borderLeft = "1px solid buttonhighlight";
el.style.borderRight = "1px solid buttonshadow";
el.style.borderTop = "1px solid buttonhighlight";
el.style.borderBottom = "1px solid buttonshadow";
el.style.padding = "1px";
}

and similarly for makePressed().

I've only performed minimal testing (IE and Firefox) so there is a lot
more work to do to make it robust, but it shows how trivial it is to
make IE-specific code into cross-browser code.

Cheers, Rob.
Jul 23 '05 #3
RobG wrote:
RobG wrote:
Brett wrote:
Is there a script for depressible buttons that work in Mozilla and IE?


[snip]
I'm sure someone here can do a better version in 10 minutes. Right now
I gotta do work...

The functions are compatible with more browsers if the following:

function makeRaised(el) {
with (el.style) {
borderLeft = "1px solid buttonhighlight";
borderRight = "1px solid buttonshadow";
borderTop = "1px solid buttonhighlight";
borderBottom = "1px solid buttonshadow";
padding = "1px";
}
}

is rewritten as:

function makeRaised(el) {
el.style.borderLeft = "1px solid buttonhighlight";
el.style.borderRight = "1px solid buttonshadow";
el.style.borderTop = "1px solid buttonhighlight";
el.style.borderBottom = "1px solid buttonshadow";
el.style.padding = "1px";
}

and similarly for makePressed().

I've only performed minimal testing (IE and Firefox) so there is a lot
more work to do to make it robust, but it shows how trivial it is to
make IE-specific code into cross-browser code.


It also shows, pretty well, how badly people can write code and have it
"published" on the web. Sad state of affairs.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Jul 23 '05 #4

"RobG" <rg***@iinet.net.auau> wrote in message
news:o3*****************@news.optus.net.au...
RobG wrote:
Brett wrote:
Is there a script for depressible buttons that work in Mozilla and IE?

[snip]
I'm sure someone here can do a better version in 10 minutes. Right now
I gotta do work...


The functions are compatible with more browsers if the following:

function makeRaised(el) {
with (el.style) {
borderLeft = "1px solid buttonhighlight";
borderRight = "1px solid buttonshadow";
borderTop = "1px solid buttonhighlight";
borderBottom = "1px solid buttonshadow";
padding = "1px";
}
}

is rewritten as:

function makeRaised(el) {
el.style.borderLeft = "1px solid buttonhighlight";
el.style.borderRight = "1px solid buttonshadow";
el.style.borderTop = "1px solid buttonhighlight";
el.style.borderBottom = "1px solid buttonshadow";
el.style.padding = "1px";
}

and similarly for makePressed().

I've only performed minimal testing (IE and Firefox) so there is a lot
more work to do to make it robust, but it shows how trivial it is to
make IE-specific code into cross-browser code.

Cheers, Rob.


Rob,

Thanks. I'm particularly interested in example 2, this code:

<div class="coolBar" style="width:100px">
<span class="coolButton" style="width:100px"
onClick="window.location='http://dynamicdrive.com'"><img src="home.gif">
<b>Back Home</b></span>
</div>

I've tried the changes you mentioned but still get no effect in Netscape
7,.2 or Firefox. Any ideas how to get the above working for those?

Thanks again,
Brett
Jul 23 '05 #5
Brett wrote:
Is there a script for depressible buttons that work in Mozilla and IE?

This works nice but only in IE:
http://www.dynamicdrive.com/dynamici...ressbutton.htm.


It doesn't look too good in IE either.

Anyway, you shouldn't be using Javascript to do this kind of thing if you
can avoid it.

Try this for example:

<STYLE type="text/css">
A {
position: relative;
top: 0px;
left: 0px;
color: #00f;
font-weight: bold;
background-color: #eef;
padding: 1px 3px 1px 3px;
border: 2px outset #aad;
}

A:active {
top: 1px;
left: 1px;
color: #000;
padding: 2px 2px 0px 4px;
border: 2px inset #aad;
}
</STYLE>
--
Philip Ronan
ph***********@virgin.net
(Please remove the "z"s if replying by email)
Jul 23 '05 #6
Brett wrote:
[snip]
Thanks. I'm particularly interested in example 2, this code:

<div class="coolBar" style="width:100px">
<span class="coolButton" style="width:100px"
onClick="window.location='http://dynamicdrive.com'"><img src="home.gif">
<b>Back Home</b></span>
</div>

I've tried the changes you mentioned but still get no effect in Netscape
7,.2 or Firefox. Any ideas how to get the above working for those?


Why use JavaScript to follow links? Users with JS disabled will click
the "link" nothing will happen. Also, the cursor will change to an
"I" bar because it's over text, not a hand pointer for a link -
confusing users. So you need to handle the cursor too...

<a href=...> was create just for links. It uses HTML, every browser
ever created knows what it is and how to use it, and you can make it
look however you want. Consider Philip's post, I've slightly adapted
it.

Cheers, Fred.
<html><head><title> button play </title>
<STYLE type="text/css">
A {
position: relative;
top: 0px;
left: 0px;
color: #00f;
font-weight: bold;
background-color: #eef;
padding: 1px 3px 1px 3px;
border: 2px outset #aad;
}

A:active {
top: 1px;
left: 1px;
color: #000;
padding: 8px 8px 8px 8px;
border: 2px inset #aad;
text-decoration: none;
}
A:visited {
top: 0px;
left: 0px;
color: #000;
padding: 8px 8px 8px 8px;
border: 2px inset #aad;
text-decoration: none;
}
</STYLE>
</head>
<body style="margin: 20px 0px 0px 20px;">

<span><a href="http://www.apple.com">Go to Apple</a></span>

</html>
Jul 23 '05 #7

"Philip Ronan" <ph***********@virgin.net> wrote in message
news:BD99480E.23EF1%ph***********@virgin.net...
Brett wrote:
Is there a script for depressible buttons that work in Mozilla and IE?

This works nice but only in IE:
http://www.dynamicdrive.com/dynamici...ressbutton.htm.


It doesn't look too good in IE either.

Anyway, you shouldn't be using Javascript to do this kind of thing if you
can avoid it.

Try this for example:

<STYLE type="text/css">
A {
position: relative;
top: 0px;
left: 0px;
color: #00f;
font-weight: bold;
background-color: #eef;
padding: 1px 3px 1px 3px;
border: 2px outset #aad;
}

A:active {
top: 1px;
left: 1px;
color: #000;
padding: 2px 2px 0px 4px;
border: 2px inset #aad;
}
</STYLE>
--
Philip Ronan
ph***********@virgin.net
(Please remove the "z"s if replying by email)


Thanks. That's pretty good. Is there a way to make it pop back up once it
is depressed.

I don't really need it for the href. I'm using an image's onClick to do
something else. I'd like to have the image (Just a colored circle) depress
rather than text. Is there a way to draw a color circle using something
similar to the above and have it depress than pop back up? I would then use
the href to direct the user to some location (actually I'm making a table
row appear).

Thanks,
Brett

Jul 23 '05 #8
"Brett" <no@spam.net> wrote in message
news:Ce********************@rcn.net...

I don't really need it for the href. I'm using an image's onClick to do
something else. I'd like to have the image (Just a colored circle)
depress
rather than text. Is there a way to draw a color circle using something
similar to the above and have it depress than pop back up? I would then
use
the href to direct the user to some location (actually I'm making a table
row appear).


You're running up against the most basic headache of the WWW.

The original intent (of the designers of the WWW and hence browsers) was to
handle text and links. Hence "HTML" as "Hyper Text Markup Language".

But, increasingly, people want to use the WWW and browsers to develop
on-line applications. So they are looking for an API that gives them
buttons, menus, dialogs, text areas, and so forth, that behave with all the
flexibility of a programming API.

This may happen. But meanwhile, you're forced to all sorts of strange
contortions to try to fit the richness of a programming API onto HTML
browsers.

You can put tons of JS on a page, and thereby do much of what you want.
Java applets provide some help, as do things like Flash, but you're still
trying to stretch things to fit. But the more you do this, the more your
page risks being browser-specific and platform-specific, the more work you
have to do, and the fewer people who will experience your UI as you
intended.

I keep hoping there's a way out of this box. Meanwhile, my advice (which I
keep repeating to myself and to my clients) is "don't try to use the Web as
a replacement for applications." For the time being, these are two separate
spaces. The closer you keep your web "applications" to the things that
browsers do well, the easier it will be to develop your code, and the easier
it will be for users to get full usefulness from your work. And, this
sucks, because you just can't get very creative.
Jul 23 '05 #9
Dana Cartwright wrote:
"Brett" <no@spam.net> wrote in message
news:Ce********************@rcn.net...
I don't really need it for the href. I'm using an image's onClick to do
something else. I'd like to have the image (Just a colored circle)
depress
rather than text. Is there a way to draw a color circle using something
similar to the above and have it depress than pop back up? I would then
use
the href to direct the user to some location (actually I'm making a table
row appear).

You're running up against the most basic headache of the WWW.

The original intent (of the designers of the WWW and hence browsers) was to
handle text and links. Hence "HTML" as "Hyper Text Markup Language".


No it wasn't. The web was before HTML. The original intent of the web,
and still is today, is the sharing of information. Nothing more, nothing
less. HTML just happens to be one method used to share that information.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Rich | last post by:
I have a project that I would Greatly Appreciate some direction. My goal is to create a "Sales Assistant Script" that recommends products based upon Response's to questions. I know enough...
18
by: Ed Jay | last post by:
<disclaimer>js newbie</disclaimer> My page has a form comprised of several radio buttons. I want to poll the buttons to determine which button was selected and convert its value to a string. I...
5
by: | last post by:
Looking to do something pretty simple... I have a cancel button on my page. When the user clicks it, i want to verify they want to cancel and if so, redirect them. Code:...
3
by: Learner | last post by:
Hello, I have two buttons on one of my VehicleDetails.aspx page. Obiviously these two buttons takes the user to two different pages. Now my client is interested in having a linkbutton instead of...
5
by: Mirovk | last post by:
The onclick action associated to my formīs radio buttons call to a vbscript were the session values are changed, this happens correctly but with the onclick action associated to my continue button...
2
by: Bundy | last post by:
Hi On my webpages I have replaced the submit button with a rolling submit button using the script below (Script 1). This script is used by many of my webpages and is included in a external...
0
by: SirMikesALot | last post by:
I'm pretty good at Excel, but my skills in Visual Basic are very limited. I found script on-line that creates & opens a user form, allows you to select your worksheets, prints the selected...
0
by: evo27 | last post by:
hi guys. I'm trying to make a navigation menu with AS tweening. So far I have all 4 buttons and a graphic inside a movie clip named "logo_mc" with an instance name of "logo_mc". I have managed...
6
by: tvnaidu | last post by:
Hi: Any stress test html script to test web page contains few radio buttons and apply. I have web page contains 8 radio buttons, just select on / off using radio button, then at the bottom, click on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.