I have a link on my parent page. When i click on it a popup opens. On the popup I have a button, when I click on it I need to change link's which is on the parent window(clicked to open popup), text and onClick event.
How can i do it?
Its better to reference a function on the parent window, rather than write code on the popup, so I'd use parent.some_function();
This way, if the original page changes, you can change the function there too, without searching through your popup windows.
You can not access tab/window elements from different tab/window.
Related
I have a button in an iframe. I want that button to trigger an event outside the iframe. How can I do that?
I have the following button
<button class="btn">Back</button>
inside an iframe
I want when people click on that button, that it triggers an event in the view outside of the iframe. How can I do that?
No need to worry about cross domain because the iframe url is on the same domain as the view.
The button only shows up when the user navigates to the second page of the iframe.
It can't, at least not directly. Events stop bubbling when they hit the top of the document.
You could do something like:
button.addEventListener("click", passEventToParent);
function passEventToParent(event) {
parent.querySelector("iframe").dispatchEvent(event);
}
See dispatchEvent on MDN for more information about it.
I have a page with a link with opening attribute '_blank'. But when click the link and open a new window, there are scripts in the new window, like 'window.opener.location' which changes the parent window's behaviors. However, this is not I wanted. How can I prevent this happening.
Thanks.
I have few element in my html page which has tabIndex attribute.
Now I have a div based modal popup window opening from this page. I have few elements in this popup window which has tabIndex.
Problem: When the user presses the tab, the focus is set to each elements in the popup window, after the last element in the popup got focus and still the user press tab the focus is going to the elements in the main page which I dont want.
Is there any way to rotate the focus on elements in the popup window itself?
If all you need is to refocus on the first element after the last element focus is out then use
Jquery's focustout() for last element and then use $('#FirstElement').focus()
I hope that helps
My page structure is like
I have a html page which consist of a jQuery Dialog.
Within the jQuery Dialog a screen opens within iFrame.
Now the problem I am facing is - I want to close jQuery Dialog by clicking a button within iFrame. (For e.g. If my iFrame source is Google.com, then on click of search button my dialog box should close)
So, Can I write close call handling click event of search button in $(document).ready(function() of my html page?
Note :- iframe source is not accessible.
If no, then what are the other possible option to do it?
Thanks in Advance.
If the iFrame source is on a different domain than you cannot do this.
Options
Use the Dialog's built in close functionality
If the position of your item that you want to trigger the close is fixed, you can overlay a div covering. Fire the close event on the clicking of the div. http://jsfiddle.net/YvbPB/
See jQuery/JavaScript: accessing contents of an iframe my friend.
I've got a simple dropdown menu that I want to hide whenever you click anywhere on the page (not on the menu). This works fine in FF and IE until you add iFrames into the page. The menu doesn't hide in IE when you click on the iFrame. Works fine in FireFox.
I tried using document.onclick and window.onclick.
Any ideas?
Edit:
I would prefer not to have to add anything to the iframe. The page is dynamic, and different iframes could be loaded after the menu has already been created. It would be a hassle/undesirable to have to constantly watch for new iFrames and attach events to them.
Yes I am aware of jQuery.live, but we don't use jQuery.
I assume this behaviour is possible since it works on FireFox, I just feel as though I may just be attaching the listener to the wrong event type or the wrong element.
On the parent page, you can search for iFrames in the page and add an onfocus event for them. That event will be fired when the user clicks within the frame.
An alternative would be to have the drop-down menu disappear after a set period of time has elapsed since the mouse or focus was on it rather than requiring a click to dismiss it.
click events bubble up to the owner window and no further. If you want the parent window to find out about clicks on the content inside another frame, you must catch events on its window/document (or have the child document catch clicks and inform its parent document). Yes, it will be a hassle, and jQuery live wouldn't work anyway since it relies on event bubbling.
Alternative approach: when you open a dropdown, also open a transparent ‘shade’ div behind it (but in front of everything else on the page including the iframes), and catch clicks on the shade to close the dropdown.