0

I don't know how to create an asp in fiddle but I created the JS.Please check the link .Imagine I have a button(button id: button2) on (src : 'ccc.de';), and when i click that button(in ccc.de) I should catch the event in js

My actual src page is not ccc.de, my src page contains an asp with a button(button id: button2) on it.

Thank you in advance

2

3 Answers 3

0

Your question has no relation to angular or JSON for that matter.

If you want to attach an event listener to your button, you can try preventing the default action of the button by doing something like this.

$("#btn").click(function(e){
 e.preventDefault();
 function_to_call();
});
Sign up to request clarification or add additional context in comments.

3 Comments

hey sorry for the title I forgot to change the title and thanks for the reply. but I am sorry to say, the solution you gave is not working
Can you make a fiddle maybe? I don't see why it should not work. Did you change #btn to whatever the id of the button is?
hey I dont know how to create an asp in fiddle but i created the JS please check the link : fiddle.sencha.com/#fiddle/14bj imagine i have a button(button ID: button2) on src : 'ccc.de', and when i click that button I should catch the event in js Thank you
0

You can do it using event delegation

    $(document).ready(function() {

         $(document).on('click', "#button2", function() {
             alert("button2 clicked");
         });
 });

//instead of document in click event, you should use parent of $button2

Or you can use

 $(document).ready(function() {

         $( "#button2").on('click', function() {
             alert("button2 clicked");
         });
 });

1 Comment

working on fiddle jsfiddle.net/30w751ew/3 but not working for me in local
0

Your code are ASP code, or ASP.NET WebForms, maybe ASP.NET MVC?

At fiddle (https://fiddle.sencha.com/#fiddle/14bj) I see iFrame. Remember, if your button in iFrame, and your code with setting event handler in owner document, you should search button for setting your event inside of iFrame. It's will be not fount in parent document. Maybe problem is here. If you have PostBack (or another things, that reloads page), and button2 inside iFrame, then botton2 event handler will be lose after iFrame reloading. So, you will need set listener for event again, because it will be new button2 after reload (inside iFrame).

If you use ExtJS, then better set event on ExtJS button by component config. Somethin like this:

Ext.create('Ext.Button', {
text: 'Button2',
renderTo: Ext.getBody(),
handler: function() {
    alert('You clicked the button 2!');
}});

Here example with two ways: https://fiddle.sencha.com/#fiddle/14hs

For better understood of your problem, culd you provide full code of this pages (if you couldn't use fiddle for asp, use http://pastebin.com/ or another service of posting sources).

I hope I wrote something helpfull (but not shure). Good luck!

5 Comments

Thanks for your reply my case a bit different please the whole code my extjs code to create window is pastebin.com/Y0X6fqSW (see from line 90) my ASP code that's called in the window is pastebin.com/QGKTSC2x (see at line 430 for button)
At first look, I see you want close ExtJS window by clicking on button in iFrame: <button class=stdbutton onclick="window.close();" id=button1 name=button1><%=lng_close%> </button> Right?
What there happens: 1) I added onload handler to iFrame autoEl (look at html) 2) In handler I found the ExtJS window, that contains this iFrame and has found the button in iFrame document. Remember that in iFrame another document, you should search the button exactly in this document. 3) I added handler with js closure, that close the window. This can help you better understand this solution: stackoverflow.com/questions/2509934/…
And one more.. Never, NEVER don't call variables in your code 'window' or 'document'. Never don't use names, that alrady used by DOM, language, etc. In your fiddle example you named local variable as 'window'. It's make many problems with debuggong and understandig of code logic in some places.
Hey bro all at once that worked like a charm millions of million likes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.