Reputation: 2897
I have two JS variables X and Y. In my markup there's a line starting with:
<iframe frameborder="0" width="600" height="337" ..
I want to replace the width's value by X's value and the height's value to Y's value. Could somebody help me with the regular expression to achieve this ?
Upvotes: 0
Views: 200
Reputation: 339955
This is not a regexp problem.
Use DOM methods to find the <iframe>
tag, and then just set its .width
and .height
properties.
For example, if there's only one <iframe>
on the page:
var iframe = document.getElementsByTagName('iframe')[0];
iframe.width = x;
iframe.height = y;
It would be better to put an ID tag on the <iframe>
, though:
var iframe = document.getElementById('myid');
... as above
If setting those properties doesn't work (it does on a Canvas, I haven't tried it on an iFrame) then set the CSS style properties instead.
Upvotes: 1