I have two different pages: the main page and the second page (that will be displayed in the main page as an iFrame).
The fact is that I cannot edit the main page, except from the iFrame href link.
What I want to do is to manually trigger the iFrame "onLoad" event in the main page, by using jQuery in the second page.
This is getting really hard cause of the impossibility to edit the main page, and the only thing I managed to do is to manually trigger the "ready" event on the second page, but this is not related to the "onLoad" event, unfortunately.
Any help would be greatly appreciated.
Thanks in advance.
Try
parent.$("iframe[src=myhref]").trigger("onload");
Related
I am trying to create a loading icon which triggers on a code behind function (Button click) the function redirects to another page. I am trying to find a way of having a loading icon appear on the button click and go away when the second page is loaded.
I have tried using Jquery by hiding the loading icon on page ready using the following function
$('#LoadingIcon').hide()
... in the document ready function.
However the icon doesn't appear until the page is already halfway through its loading process.
Any guidance on how I could solve this would be greatly appreciated.
Please use the following link which may help you to do this. There's a way to do it using a bit of JavaScript.
http://blog.ysatech.com/post/2010/02/06/ASPNET-redirect-a-web-page-with-AJAX-loading-indicator-image
I'm trying to set up event, which should fire when iframe is loaded. It is important to acknowledge, that I want this event to fire INSIDE iframe, not in parent page. Actually, parent doesn't have to know that iframe was loaded.
On the beggining I've tried $(function() {....} (document.ready) event, but it doesn't seem to work as expected. It seems that it fires when parent page was loaded (the same event on parent page works as expexted).
Then, I've tried window.onLoad = function() {...} but it doesn't seem to work at all (event not fired).
So, how to do that? Again, I'd like the page inside iframe to know that loading was complete. Basically, I'd like to have event, that will work in iframe page as $(function() {}) in parent page.
I am afraid you can't do this in a right way.
See this link : How to add onload event to a div element?
May be somebody should post the ticket to github.
If you own the page being loaded into the iframe, put the code in the page being shown in the iframe, not the parent page. If you do not own the page being loaded into the iframe, you cannot do what you're attempting due to cross-domain security sandbox restrictions. You would need a CORs solution http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
When the home page loads, $(document).ready works. When I click on a link that goes to the homepage, $(document).ready doesn't fire again.
I need it because I attach some events to the dom inside $(document).ready function. For whatever reason those attached events get removed when I click on the home page link.
How do I fix this?
Any event should be attach outside $(document).ready(), could be before
$(document).on('click', 'mySelector', function(){});
This will fire no matter what
I figured it out. rails 4 uses a js library called turbolinks. This was doing some sort of optimization that changes page without doing a full reload. You can fix this be removing turbolinks or using their own hooks to load scripts.
I'm tying in to the onbeforeunload event in Javascript to disable control of the page during the unload process. We have a bunch of users who were editing data during this time and it was wreaking havoc on the product.
There are a bunch of links that show up on the page that have href="javascript:.....".
Clicking these links fires the disabling code, which makes the page impossible to use. Is there a way I can detect if the onbeforeunload event is navigating to a different page or just firing this Javascript?
Have every href link visit a piece of javascript code which does inspection on the href contents before it is executed.
event.target.href.startsWith('javascript')
If yes, submit the request, if not, do something else.
This isn't the most reliable way of checking for this but it works for my purposes:
$('*:focus').attr('href')
I have been trying to have a small login widget that I embed within a static page inside an iframe allow someone to log into my site. The problem I get is that when the form posts it ends up appearing inside the iframe instead of as a full browser page.
I know it is possible to do this because https://www.salliemae.com/ employs the same strategy on their home page. They embed an iframe inside their static page that does all their logic for them. I have very similar javascript in that I call form.submit() when someone clicks. The only difference is that I use jQuery to catch the click event vs putting the onclick directly on the form element.
I have looked at their code in their calm.js and it seems to be doing a simple form.submit() as I do, but their page loads fully in the browser vs only in the iframe. I have looked around SO and not seen a similar post, so if I just missed it, please let me know.
See target="_top" in the iframe's <form> tag. That tells the browser to load the response in the parent frame.
If you do not ajax the content, you just add target="_top" to the form, otherwise you will have to use window.open(*serialisedurl*,"_top")