Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

refresh an iframe without a src

Featured Replies

Hi, i am building a front end developer testing area like js fiddle i have what i want working, it works by loadiing a file and using php file_put_contents to update the file, the way i would like it to work is the posted data to populate the results are (this i can do) the problem i have is if you choose a javascript library like jquery to load into the iframe the iframe needs to be refreshed for the jquery to work and then the results go blank

 

HTML

<iframe class="iframe_layout_with_sidebar" src="./files/test.php" id="view"></iframe>

 

AJAX

		$.ajax({
			url: '/convert',
			type: 'POST',
			dataType: 'HTML',
			data: { 	html: html,
			css: css,
			js: js,
			jquery: jquery,
			jqueryUI: jqueryUI,
			ko: ko,
			option: 'save'
		},
		})
			.done(function(data) {
				document.getElementById('view').contentWindow.location.reload(true);
			})

php just updates the test.php file with file_put_contents

 

this works but i want it to load the iframe with jquery loaded and with the posted data

 

thank you

  • Author

Solved this, after the ajax call added

.done(function(data) {

      var result = data;
      var iframe = document.getElementById('view');
      if(iframe.contentDocument) doc = iframe.contentDocument;
      else if(iframe.contentWindow) doc = iframe.contentWindow.document;
      else doc = iframe.document;
 
      doc.open();
      doc.writeln(result);
      doc.close(); 
})

this updates the iframe and refreshes the iframe so it works like js fiddle

Is it also possible to achieve this with meta refresh? Like so (adding this to your PHP file)

 

<meta http-equiv="refresh" content="10">

Just an idea, would this work?

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.