Sam Kingston
Sam Kingston

Reputation: 877

Append a No Redirect to Iframe src using javascript

I have the following

 <iframe src="http://website.com:352/pictures/1">

How would I append a No Redirect such as upon visiting

"http://website.com:352/pictures/1?noRedirect"

Upvotes: 0

Views: 92

Answers (1)

Victory
Victory

Reputation: 5890

Give the iframe and id so you can get a handle on it, also change src to data-src on the initial DOM so that non redirect is not automatically loaded.

<iframe id="myIframe" data-src="http://website.com:352/pictures/1">

The you can add the no redirect param on load

jQuery(function() {
  var $iframe = $("#myIframe");
  var src = $iframe.attr('data-src');
  $iframe.attr('src', src + "?noRedirect");
});

Upvotes: 1

Related Questions