By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,213 Members | 1,083 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,213 IT Pros & Developers. It's quick & easy.

Javascript Button Click

P: n/a
This problem only exists in IE, due to UI restrictions I'm using a
href in an error label to bring up a modal popup. I'm using a callback
to filter a grid on the popup.

The problem:

The href has javascript:btn.click() basically, which in Firefox causes
a postback after it's clicked. IE works fine without posting back,
this is suppose to be an instant popup and the postback defeats the
whole purpose. Any ideas?

Sep 18 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
On Sep 18, 9:08 am, Deft....@gmail.com wrote:
This problem only exists in IE, due to UI restrictions I'm using a
href in an error label to bring up a modal popup. I'm using a callback
to filter a grid on the popup.

The problem:

The href has javascript:btn.click() basically, which in Firefox causes
a postback after it's clicked. IE works fine without posting back,
this is suppose to be an instant popup and the postback defeats the
whole purpose. Any ideas?
Sorry correction this problem only occurs in Firefox, sorry for the
confusion.

Sep 18 '07 #2

P: n/a
I've found a solution, Firefox does not treat element.click() the same
as IE, I decided to use the element.dispatchEvent(evt) for other
browsers, IE does not support dispatchEvent, rather fireEvent.

BTW, pointedears, I find it astonishing you are replying to a
javascript thread without knowing the term postback.

http://en.wikipedia.org/wiki/Postback

Thanks anyway for the suggestion on removing the javascript:method()
syntax, I have since replaced it.

Sep 18 '07 #3

P: n/a
De******@gmail.com wrote:
[...]
BTW, pointedears, I find it astonishing you are replying to a
javascript thread without knowing the term postback.

http://en.wikipedia.org/wiki/Postback
| This article is considered orphaned, since there
| are few or no other articles linked to this one.
| [...]
| This software-related article is a stub.
Thanks anyway for the suggestion on removing the javascript:method()
syntax, I have since replaced it.
Good.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Sep 18 '07 #4

P: n/a
On Sep 18, 10:16 am, Deft....@gmail.com wrote:
I've found a solution, Firefox does not treat element.click() the same
as IE, I decided to use the element.dispatchEvent(evt) for other
browsers, IE does not support dispatchEvent, rather fireEvent.

BTW, pointedears, I find it astonishing you are replying to a
javascript thread without knowing the term postback.

http://en.wikipedia.org/wiki/Postback

Thanks anyway for the suggestion on removing the javascript:method()
syntax, I have since replaced it.
The term postback has nothing to do with javascript. It is a term used
in .NET to describe web pages being sent to the server for server-side
processing and has nothing to do with javascript.

Sep 18 '07 #5

P: n/a
On Sep 18, 3:23 pm, Deft....@gmail.com wrote:
The href has javascript:btn.click() basically, which in Firefox causes
a postback after it's clicked. IE works fine without posting back,
I have recently found that in situations where you want to avoid
displaying the script result in the browser window (which I assume is
what you mean by postback) you can try replacing

javascript:something

with

javascript:function(){something();}()

It's ever so slightly weird, but it does the trick. Can be used for
adding scripts to your bookmarks too, if ever you had reason to do so.

Sep 19 '07 #6

P: n/a
AndrewTK wrote:
On Sep 18, 3:23 pm, Deft....@gmail.com wrote:
>>The href has javascript:btn.click() basically, which in Firefox causes
a postback after it's clicked. IE works fine without posting back,

I have recently found that in situations where you want to avoid
displaying the script result in the browser window (which I assume is
what you mean by postback) you can try replacing

javascript:something

with

javascript:function(){something();}()

It's ever so slightly weird, but it does the trick. Can be used for
adding scripts to your bookmarks too, if ever you had reason to do so.
It "does the trick" because that function returns `undefined'.
void(something()) would also have "worked".

*Please* read the FAQ before posting:

http://jibbering.com/faq/#FAQ2_3
http://jibbering.com/faq/#FAQ4_24

It is not that hard to miss, especially as the FAQ Poster script will post
each single FAQ here frequently.
PointedEars
--
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Sep 19 '07 #7

P: n/a
On Sep 19, 7:22 am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
AndrewTK wrote:
On Sep 18, 3:23 pm, Deft....@gmail.com wrote:
>The href has javascript:btn.click() basically, which in Firefox causes
a postback after it's clicked. IE works fine without posting back,
I have recently found that in situations where you want to avoid
displaying the script result in the browser window (which I assume is
what you mean by postback) you can try replacing
javascript:something
with
javascript:function(){something();}()
It's ever so slightly weird, but it does the trick. Can be used for
adding scripts to your bookmarks too, if ever you had reason to do so.

It "does the trick" because that function returns `undefined'.
void(something()) would also have "worked".

*Please* read the FAQ before posting:

http://jibbering.com/faq/#FAQ2_3http...m/faq/#FAQ4_24

It is not that hard to miss, especially as the FAQ Poster script will post
each single FAQ here frequently.

PointedEars
--
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>- Hide quoted text -

- Show quoted text -
Yes that would stop the postback but doesn't do the trick in this
situation. I posted the solution, which is completley javascript
related and not in the FAQ though it could be.

The real breakdown here is that other browsers don't treat
button.click() the same as their dispatchEvent(evnt), which is non-
intuitive. This was tested with Firefox and IE, IE doesn't support
dispatchEvent instead fireEvent. I want a real standard to call for
clicking a button via javascript, without conditional
statements. .click() is supported by the 2 main browsers but
implemented totally different.

Does anyone have an explanation for this behavior? I just want to know
if there is a real reason not to simply call the dispatchEvent(evnt)
from .click(). I'm not one to defend IE, but their .click() method
works, in my testing, just like their fireEvent() method. I'm not
sure why Firefox in this example treats the click() and
dispatchEvent() methods differently. I would guess security related,
but I'm not sure.

So Postback isn't javascript related, ok but what do you call when the
page refreshes in javascript terms? Just a Post? I am a .NET developer
but I was assuming Postback was a geneic web developer term.

-Jab

Sep 19 '07 #8

P: n/a
On Sep 19, 2:55 pm, Deft....@gmail.com wrote:
<snip>
So Postback isn't javascript related, ok but what do you call
when the page refreshes in javascript terms?
It is doubtful that you ever do "refreshes in javascript". Possibly
"with javascript" but then you would have to be specific about what
"refreshes" was intended to mean.
Just a Post? I am a .NET developer
but I was assuming Postback was a geneic web developer term.
When what you are describing are HTTP transactions the terminology
from HTTP is the precise, unambiguous and (theoretically) universal
tool for describing them.

Incidentally, that wikipedia page is worse than useless as "the entire
page and its contents are sent back to the server for processing" is
extremely unlikely to be true, as that would be both difficult to do
and a stupid thing to attempt.

Sep 19 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.