Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 723977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:10:11+00:00 2026-05-14T06:10:11+00:00

In the [webView:shouldStartLoadWithRequest:navigationType:] event, how can you tell the difference between an iframe that’s

  • 0

In the [webView:shouldStartLoadWithRequest:navigationType:] event, how can you tell the difference between an iframe that’s loading content vs. the entire page loading content? It seems like the both call this same event with the same arguments, the only difference being the URL that’s going to be loaded, so there is no way to tell the difference between the two.

I’ve thought of a few ways to tell the difference though:

  • Parse the source code of the page and store a list of all the iframe src attributes, assume that if the url loading is one of those in my list it’s an iframe. Of course this assumption might be incorrect if it actually does navigate to the page.
  • Same as above, but run some JavaScript on the page and to get the iframe src attributes.
  • Using JavaScript, set up hooks for whenever a user tries to navigate to a page, similar to http://niw.at/articles/2009/02/06/how-to-enable-the-popup-window-on-uiwebview/en
  • Using JavaScript, set up hooks right before an iframe tries loading data (not sure how I would do something like this).
  • Modify each iframe’s src attribute to include a special string at the end of it’s src attribute e.g. “#iframe-loading”. Load the UIWebView with this modified source code. Although this will only work for iframes that existed on the original page as it was queried the first time, not those that are loaded dynamically, e.g. via JavaScript.
  • Let the page load normally by returning YES in the [webView:shouldStartLoadWithRequest:navigationType:] event, and once it’s done loading, see if the WebView’s URL changed or not… if it did that means it was a page redirect if not it probably means it was an iframe that was loaded.
  • Using JavaScript, override the window.location property setter to run my own code before it will actually change the window’s location. I could then communicate with Objective-C to let it know that the next load is actually going to be a redirect. Is this the only way to redirect in JavaScript though?

What’s the best way to do this? Can you think of any ways I haven’t thought of? Do iframes have a special event/property I could manipulate with JavaScript to help me out?

Thanks

Update: It’s not as simple as just checking the navigationType. Although clicking a link to open up a new page will show up as navigationType = 0, a JavaScript redirect (changing window.location) will show up as navigationType = 5. An iframe load also shows up as navigationType = 5. So when navigationType = 5, you don’t know if the entire page changed URLs via JavaScript or if it is simply an iframe loading on the same page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:10:12+00:00Added an answer on May 14, 2026 at 6:10 am

    I just used this method:

    Let the page load normally by returning YES in the [webView:shouldStartLoadWithRequest:navigationType:] event, and once it’s done loading, see if the WebView’s URL changed or not… if it did that means it was a page redirect if not it probably means it was an iframe that was loaded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm loading a local web page and intercepting web clicks using: (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { BOOL bLoadRequest = YES; if (this is
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { //my code } Currently my above delegate
-(bool) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{ if (navigationType == UIWebViewNavigationTypeLinkClicked) { NSURL *url =
I'm using the webView:shouldStartLoadWithRequest:navigationType method to call my Objective-C code from JavaScript which works
webview in android loads more than once while loading the url. Below is the
My webview will works for a site such as Google.com, however, the specific page
A Webview will display links in the content HTML as having blue underlines. So
I use WebView + addJavascriptInterface to control my app from html page shown in
I'm loading in a UIWebView from another class, and that works great. But now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.