Javascript Button Click

D

Deft.Jab

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?
 
D

Deft.Jab

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.
 
T

Thomas 'PointedEars' Lahn

[Quotation adapted according to OP's correction]

This problem only exists in [Firefox], 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.
OK

The problem:

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

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


PointedEars
 
D

Deft.Jab

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.
 
T

Thomas 'PointedEars' Lahn

[...]
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
 
D

dave

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.
 
A

AndrewTK

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.
 
T

Thomas 'PointedEars' Lahn

AndrewTK said:
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
 
D

Deft.Jab

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://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>- 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
 
H

Henry

On Sep 19, 2:55 pm, (e-mail address removed) wrote:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,408
Latest member
AlenaRay88

Latest Threads

Top