I google it up but didn' find something like this.
I am having an iframe with 2 main attributes src=# and link=http://somesite.com
<iframe id="myiframe" src="#" link="https://somesite.com?id=x&anotherid=y" style="position:absolute; left:0px; top:0px; width:99%; min-width:80%; height:99%; min-height:80%; padding:0px;"></iframe>
I load that iframe in HTML from some php script but i don't want to load the page thats why i used # as source, now when i click a button on the site it will load the iframe (if it was not loaded from a previous click), my temporary solution was:
<input type="button" value="load" onClick="var fr = document.getElementById('myiframe');if(fr.src.substr(-1)=='#'){fr.src=document.fr.getAttribute('link')};" />
Now I had a little time to implement the jQuery and I whant to know if there is some simple code in jQuery to copy from an attribute to another, or if there is a better solution to accomplish this.
something like this: $('#myiframe').attr('src', attr('link'));
i know the folowing will work
$('#myiframe').attr('src', attr('link'));
but i think is not to much to select the same element twice. (I am kind of an optimizer maniac :) )
or you think that I have to use a function:
$('#myiframe').attr('src', function(){
...
});
My question is what is the best way to achieve this. Thank you.