Using javascript to stop page loading [duplicate] - javascript

This question already has answers here:
Stopping a iframe from loading a page using javascript
(6 answers)
Closed 7 years ago.
Is there a way in javascript to simulate pressing the "stop" button the browser whenever a link or button is clicked?
I'm trying to load other websites while displaying a frame at the top of the page, the issue is that sometimes it takes a while to load all the content on a page (especially if there is something being streamed). Is there anyway to make it so I can place a "stop" button or link on my top frame that ceases the loading of anything else?
I checked around but couldn't find anything
Thank you!

You can use the window.stop() method, however note that depending on the location of your script, JavaScript is not executed until after the DOM (typical practice), so often times the page will already be loaded before this executes.
For an iframe, simply target the frame and use the stop method.

Related

Updating an area of my webpage with another site WITHOUT looking like a hacker [duplicate]

This question already has answers here:
Overcoming "Display forbidden by X-Frame-Options"
(27 answers)
Closed 3 years ago.
I'm trying to build a webpage with the following specs:
A list of buttons on top
An area underneath the buttons where other websites can render
When a button is pushed, the area renders a different website
Seems pretty simple. So I built this with a few JS buttons on top and an iFrame below it. When I receive an onClick, I simply change the src attribute on the iFrame.
This works very well. Until... I try to put Google into the iFrame. Google refuses because it sets 'X-Frame-Options' to 'SAMEORIGIN'.
I fully understand what's happening here and more importantly, why it happens. But I still need to build this page.
Is there any way to get what I want without resorting to things that makes it look like I'm doing something unsavory? And yes, I realize I'm sort of duplicating the functionality of a browser window with a list of bookmarks, but I need things to look and operate in a certain way.
You could offer a search box and a submit button on a custom 'google' page which your iframe looks at (just a local script) and send the user to a new tab with that search automatically entered into Google. You cannot gleam anything from the iframe anyway so this wouldn't take away from your ability to do anything (other than keep the user on your tab), but if they're going to Google, you just don't have the choice.

Programmatically Scroll External Webpage to Load Content [duplicate]

This question already has an answer here:
Scroll down to bottom of infinite page with PhantomJS in Python
(1 answer)
Closed 5 years ago.
I am trying to scrape a (very long) webpage for some content.
I am using Python's BeatifulSoup library, but am not limited to Python. The issue I am facing is that the page only loads a small subset of the content, and, as soon as the user scrolls to the top/bottom of the page, more content is loaded.
There is a javascript function that is called when the scroll-bar hits the top/bottom, triggering the server to load more data. Is there a way for me to programmatically scroll through the page, or call the function that gets the page to load more data, so I have all the content available?
I know I could just use VBScript to control the window and scroll, but ideally I am looking for a more elegant solution that allows to me to extract the data and scroll the page at the same time.
You can check following answer OR you can check the net panel and call the same url or method which gets called when page hits the bottom of the page

Embedding Third Party Content in HTML Website [duplicate]

This question already has answers here:
Javascript back button for iframe parent window
(2 answers)
Closed 9 years ago.
I want to embed some third party content which will be an html page, inside my html website. I thought of using the iframe approach in which i will embed the third party html page inside my website as an iframe.
The motivation behind using iframes was that i dont know what libraries they might use, or what CSS they might write. I wanted their logic to be separate from mine. Iframe fulfills my this wish.
But now i have a problem, if i want the browser Back/Next Functionality for any navigation's inside the iframe, it will be very difficult to maintain because of the route. At the same time, maintaining the iframe state when the parent page is refreshed will be pretty tough.
So, is the iframe approach fine first of all? If it is, then how do i cater to the Browser Back/Next?
Well, you can manage back/forward button with JavaScript like this:
iframe.contentWindow.history.back();
iframe.contentWindow.history.forward();
Bigger problem is that included page can disallow possibility to be included into iframe (if you include page with this behaviour into iframe, it will load over your page - check for example this qeustion).

Call a javascript function from an iframe [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Iframe Function Calling From Iframe to parent page javascript function
I have a JavaScript function written in my main page. It's a function that slides up the div "toggle" (with jquery).
This main page contains an iframe that is embedded into the div#toggle.
When I click on a link that belongs to the iframe I would like to execute the slide up function.
I put an onclick event on a link in the iframe (to trigger the function declared in my main page) but it doesn't work. Well, I'm not that surprised but I don't know how to make it work.
Does anyone has an idea ?
You can use window.parent to access the containing page:
window.parent.someToggleFunc();
Note that Javascript access between iframes like this are subject to the Same Origin Policy.

how is this slider done it looks to be js but its altering the url with each slide [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Modify the URL without reloading the page
I just came across this site, http://www.so-design.co.uk/#/brand/1 , if you use the slider it changes the image just like any normal image slider but it also changes the url to /brand/1, /brand/2 ect which i suppose means that all the slides and their content are crawled by search engines as individual pages
any ideas how they are doing this ?
cheers
You might want to take a look at manipulating the browser's history as well as the history property. Also, reading the hash usingwindow.location.hash
First thing to do when you want to try and work out how a website has been developed is to view the source code.
The quickest way to do this is to right-click the page and look for "View page source" or something similar (depending on your browser)
Of course, in this instance, when you right-click it should become obvious that the website uses Adobe Flash. Therefore, this is not a typical JavaScript slider as you first seemed to assume.

Categories

Resources