I have a select box and a iframe. when I change the select option the content in the iframe needs to change. I used jquery to change the iframe src.
To change the src I have used the following code. It works,If I see in the view source I can see the change of src value.But the content is not changing in the iframe.
$('#myframe').attr('src', "http://www.option"+value+".html");
Question: How to make this new src url to load my iframe?
You shouldn't use this tactic (there are various issues with it, IE dislikes blank srcs for example).
Instead, remove and recreate a new iframe with the new src.
$('#myframe')
.before('<iframe src="blah.htm"></iframe>')
.remove();
Related
in my website I use flipbooks made with Flip PDF Professional (here's an example: https://istitutometacultura.org/progetto_babar/storie_di_babar/il_ritorno_a_casa_di_babar/microstoria.html), and I embed them into the pages using iframes (example of parent page with embedded flipbook: https://edumediateca.istitutometacultura.org/il-ritorno-a-casa-di-babar2/). These flipbooks also have the function of opening directly to a specific page, if you add "#p=X" to the end (X is the page number). Now, sometimes I need to link a specific page of the flipbook, so the flipbook link will be, for example, "https://istitutometacultura.org/progetto_babar/storie_di_babar/il_ritorno_a_casa_di_babar/microstoria.html#p=5", but this will take me to the html page, and I want the user to be taken to the page with the iframe (https://edumediateca.istitutometacultura.org/il-ritorno-a-casa-di-babar2/), not to the html file.
Since I don't want to duplicate the page just to add "#p=5" to the iframe's src, is there a way to add a value to the end of the src maybe putting it into the parent page url? (for example, if the url is https://edumediateca.istitutometacultura.org/il-ritorno-a-casa-di-babar2#p=5 the iframe's src will change from "......html" to "......html#p=5"). I don't know what to do, I really need this mechanism to work in order to publish my services... Something in Javascript or C#?
I dont want to show src attribute of video tag in source code and inspect element.
their is any way to do it using javascript. i want to hide or display different URL in video tags SRC attribute using javascript.
Welcome to HTML5 video. What you're requesting is impossible !
There is no way to hide this tag.
There is no way to do it using HTML5/JS. You can, of course set the src property of video object in DOM using JS but src will be visible in the inspector.
I am trying to create a layout/style editor similar to what is available on blogger. I noticed that they use an iframe, but the iframe has to refresh everytime you make a change. I am looking to do something more responsive. For example, if i change the width of a div I would like to see this change happening while I move the slider.
I was wondering if something like this is possible with the iframe setup using jquery/etc to modify the source of what is in the iframe, or is it better to not use an iframe?
The iframe would be used to load an existing webpage that is online.
The good thing with an iframe is that is not interfeering the rest of the page (you can use diffrent CSS, scripts, variable names and so on). TinyMCE and other editors uses iframe for its content. And yes its possible to access the iframe directly from jQuery:
See this link, http://jsbin.com/ajatix/edit#javascript,html,live
I would like to Empty contents of a iframe without touching the src. Probably using jquery. Say some thing like setting the innerHTML of body inside iframe to  
I have tried the following and it didnt work
$("#Top iframe body").html(' ');
If the iframe is on a different domain, its contents are off-limits to your page. There's nothing you can do about that - except remove or hide the whole container... or change the src.
If it is on the same domain, you can do it but the syntax is different - use .contents().
Why doesn't
$(window['iframeName'].document.body).html()
...work when i change .attr('src')
When i set the src attribute of iframe to any url when i creating the page, this code
$(window['iframeName'].document.body).html()
...will work.
But when i change the src attribute by .attr('src',"www.google.com.sa") and wait to load the page,
$(window['iframeName'].document.body).html()
...will doesn't work.
Where is the problem ?
try:
.attr('src',"http://www.google.com.sa")
When you load a page from a different domain in the iframe, you can't access it. This is for security reasons.
A couple of things:
Firstly, setting attr('src') will create a new history item. You should consider if you actually want to do that, e.g. if someone can click the back button and get the last page. If you don't want the changed state in the history (desirable for ads or apps that use iframes instead of outright ajaex), then you would want to change the document's location instead.
Secondly, I find it much easier to interact with the page like this:
$("#frameID").contents().find("jquery selector");
You can get the full HTML using a call ilke this:
$("#frameID").contents(document).children().html()