How to refresh iframe url?


test user

I'm using ionic to create an app where iframes are being used to display URLs. Here is the HTML code:

  <iframe id="myFrame" width="100%" height={{iframeHeight}}>

Here is the angular js:

 $scope.iframeHeight = window.innerHeight;
                        document.getElementById("myFrame").src = value['url'];

Everything works fine, but when I make changes on the website from the backend and refresh the app, the new changes don't appear in the app.

Pankaj Parkar

What you are doing in your code is not a valid method. You're manipulating the DOM using native methods that don't run a digest cycle, you need to do it manually $scope.$apply(). That would solve your problem, but generally you shouldn't be doing DOM manipulation from controllers that are considered BAD practices. Instead, I recommend you to use the angular two-way binding feature. Assign the url in the scope scope variable, then add ng-src="{{url}}"that srcurl to the iframe tag using , so the url will be updated in angular and the content will be loaded iframefrom the srcurl as the url is updated .

HTML

<iframe id="myFrame" width="100%" ng-src="{{url}}" height={{iframeHeight}}>

code

$scope.url = "http://example.com"

When you change the scope variable in the controller , the content of the srciframe also changes and the content is reloaded.iframe

Updates

To fix the caching issue you need to append the current datetime to your url which will create a new url each time and will not be cached by the browser. Using it like this $scope.url = "http://example.com?dummyVar="+ (new Date()).getTime()will never harm your current behavior, it just requires you to add dummyVarthe current time value, which will always be unique.

$scope.url = "http://example.com?dummyVar="+ (new Date()).getTime()

Related


How to refresh iframe url?

test user I'm using ionic to create an app where iframes are being used to display URLs. Here is the HTML code: <iframe id="myFrame" width="100%" height={{iframeHeight}}> Here is the angular js: $scope.iframeHeight = window.innerHeight;

How to refresh iframe url?

test user I'm using ionic to create an app where iframes are being used to display URLs. Here is the HTML code: <iframe id="myFrame" width="100%" height={{iframeHeight}}> Here is the angular js: $scope.iframeHeight = window.innerHeight;

How to refresh an IFrame using JavaScript?

Elitmiar I have a webpage with an IFrame and a Button, once the button is pressed, I need to refresh the IFrame. If possible, is this possible? I searched and couldn't find any answer. kjagiello : var iframe = document.getElementById('youriframe'); iframe.src

How to refresh an IFrame using JavaScript?

Elitmiar I have a webpage with an IFrame and a Button, once the button is pressed, I need to refresh the IFrame. If possible, is this possible? I searched and couldn't find any answer. kjagiello : var iframe = document.getElementById('youriframe'); iframe.src

How to refresh an IFrame using JavaScript?

Elitmiar I have a webpage with an IFrame and a Button, once the button is pressed, I need to refresh the IFrame. If possible, is this possible? I searched and couldn't find any answer. kjagiello : var iframe = document.getElementById('youriframe'); iframe.src

How to get the url of the iframe?

Lundro How to get an iframe that loads a page in another website (CORS) ?URL iFrameObject.contentWindow.location.href return the goodsCORS Error renew: The user will navigate inside the iframe and get another url which I don't know. This is what I'm checking

How to get the url of the iframe?

Lundro How to get an iframe that loads a page in another website (CORS) ?URL iFrameObject.contentWindow.location.href return the goodsCORS Error renew: The user will navigate inside the iframe and get another url which I don't know. This is what I'm checking

How to refresh iframe after regular interval in HTML

pin up I want to automatically refresh an iframe that loads a php page, but refresh the whole page instead of just the iframe. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns

How to refresh iframe after regular interval in HTML

pin up I want to automatically refresh an iframe that loads a php page, but refresh the whole page instead of just the iframe. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns

How to detect current iframe url?

india joleti I wrote a html code to initialize the iframe with another website. My domain name is for example: www.mydomain.com/Index.html at this <iframe src = "www.anotherdomain.com/pages/firstPage.html"/> I want to detect the full new src url whenever the

How to access parameters of URL in iframe?

Javier Munoz I have the following HTML with jQuery code: <div id="info" style="width: 100%; height: 280px; overflow-y: scroll;"></div> var url1 = cbcWMS1.getGetFeatureInfoUrl (evt.coordinate, viewResolution, 'EPSG:3857', {'INFO_FORMAT': 'text/html'}); $('#in

How to rotate url in iFrame in javascript

dzmr83 I have 2 arrays (I read from XML file): urlsInclude URL durationsContains an integer representing seconds I want to iterate through these arrays ( starting from the beginning 0when reaching the end ) to display in an iFrame: urls[0].innerHTMLin duration

How to detect current iframe url?

india joleti I wrote a html code to initialize the iframe with another website. My domain name is for example: www.mydomain.com/Index.html at this <iframe src = "www.anotherdomain.com/pages/firstPage.html"/> I want to detect the full new src url whenever the

How to access parameters of URL in iframe?

Javier Munoz I have the following HTML with jQuery code: <div id="info" style="width: 100%; height: 280px; overflow-y: scroll;"></div> var url1 = cbcWMS1.getGetFeatureInfoUrl (evt.coordinate, viewResolution, 'EPSG:3857', {'INFO_FORMAT': 'text/html'}); $('#in

How to execute https:// url in iframe

Dexter this is my code <!DOCTYPE html> <html lang="en"> <head> </head> <body> <div id="container"> <iframe src="https://google.com" style="width:1000px;height:1000px"></iframe> </div> </body> </html> and console error, i.e. Refused to display 'https://w

How to detect current iframe url?

india joleti I wrote a html code to initialize the iframe with another website. My domain name is for example: www.mydomain.com/Index.html at this <iframe src = "www.anotherdomain.com/pages/firstPage.html"/> I want to detect the complete new src url whenever

How to detect current iframe url?

india joleti I wrote a html code to initialize the iframe with another website. My domain name is for example: www.mydomain.com/Index.html at this <iframe src = "www.anotherdomain.com/pages/firstPage.html"/> I want to detect the full new src url whenever the

How to execute https:// url in iframe

Dexter this is my code <!DOCTYPE html> <html lang="en"> <head> </head> <body> <div id="container"> <iframe src="https://google.com" style="width:1000px;height:1000px"></iframe> </div> </body> </html> and console error, i.e. Refused to display 'https://w

How to detect iframe url jumping to another url

Yang Jian| I have a page login.php using iframe "src= http: //def.com/login ". My domain is example.com. After logout, the def.com jumps to http://def.com/home I want my page to jump from http://def.com/home to the iframe URL of my page http://example.com/logi

How to detect iframe url jumping to another url

Yang Jian| I have a page login.php using iframe "src= http: //def.com/login ". My domain is example.com. After logout, the def.com jumps to http://def.com/home I want my page to jump from http://def.com/home to the iframe URL of my page http://example.com/logi

Need an iframe to auto refresh

Taylor Tracy I'm running into a situation where the iframe needs to be refreshed about every 30 seconds. I've browsed the forums and tried a few things with no success. <iframe id="Doyle" src="http://www.dot.ca.gov/dist2/rwis/sm_doyle.php" width="375" height=

Refresh iframe content in AngularJS

Amash I am writing an application which is part of Angular and jQuery. I separate them by loading the jQuery content in an iFrame. I need to refresh the iFrame on some event (eg click on ng). My controller contains the following code: $scope.refreshIframe = fu

Need an iframe to auto refresh

Taylor Tracy I'm running into a situation where the iframe needs to be refreshed about every 30 seconds. I've browsed the forums and tried a few things with no success. <iframe id="Doyle" src="http://www.dot.ca.gov/dist2/rwis/sm_doyle.php" width="375" height=

Need an iframe to auto refresh

Taylor Tracy I'm running into a situation where the iframe needs to be refreshed about every 30 seconds. I've browsed the forums and tried a few things with no success. <iframe id="Doyle" src="http://www.dot.ca.gov/dist2/rwis/sm_doyle.php" width="375" height=

Refresh iframe content in AngularJS

Amash I am writing an application which is part of Angular and jQuery. I detach them by loading the jQuery content into an iFrame. I need to refresh the iFrame when a certain event occurs (eg click on ng). My controller contains the following code: $scope.refr

Refresh iframe content in AngularJS

Amash I am writing an application which is part of Angular and jQuery. I detach them by loading the jQuery content into an iFrame. I need to refresh the iFrame when a certain event occurs (eg click on ng). My controller contains the following code: $scope.refr

target refresh iframe

Charles Fichte I have two frames nav.html and main.html which are included in a page called index.html. I have three image links, back, forward and refresh. main.html iframe has id="main" and buttons have their respective targets. Forward and backward work fin