I am storing html of error pages of my site in sql table, i want to display them in a window, on the admin side, but not able to load the saved html in iframe, i am using asp.net mvc2.
its needed to save the pages, and display later to admin.
please suggest me right direction.
Thank you.
If you want it in an iframe, just write a severside script that takes this HTML and wraps it in a HTML doc dynamically: .... etc. Make this script publicly visible and pass some params to tell it what to display:
http://www.foo.com/iframescript.asp?html_display_params=saved_html
then:
<iframe src="http://www.foo.com/iframescript....
or: $('#iframeid').attr('src', 'http://www.foo.com/iframescript.asp....
you get the idea....
iframe means another url location, if you want to view something in an iframe it has to be it's own page.....
otherwise you want a normal frame.
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'm trying to create a page adaptive share button using the page's current URL (since the page varies from our customer to customer numbers). In the following code, there is a "script" and in it the element I need to make use the current pages url, "data-url". Is that possible?
<script type="IN/Share" data-url="thispagesurl" data-counter="top"></script>
Instead of quotes would I use some sort of variable in javascript or aspx? I'm really not sure since I honestly don't know that much about js.
You may need to do something server side.
It's possible to access and modify the script tag: (Assuming yours is the first script tag on the page)
document.getElementsByTagName('script')[0].setAttribute('data-url', window.location.href)
However this most likely won't work as scripts will have already loaded their content
How can one load a HTML file and run javascript embedded in it to construct full HTML page programatically in the same way as done by browsers?
Edit 1 - I have an application where I am trying to read some data embedded in an html page of a remote website. However, after fetching this page from remote website, I don't see that data because that data is actually loaded by a javascript embedded in this HTML page after browser loads initial markup. So, I need a way in my application to trigger javascript embedded in the HTML page in order to construct full HTML page.
If you mean that you have an HTML file stored on your computer, the only way that you can compile it is with your browser. Just enter the absolute file path in your browser's url input. If I misunderstood your question, leave a comment and I'll correct my answer.
Question needs more details, but depending on what you want:
If you want to dynamically load different HTML documents, see iFrame
If you want to insert elements to an empty html document:
First, make a blank html document
<!DOCTYPE html>
<script src='main.js'></script>
</html>
Then in main.js do:
var html = document.querySelector('html');
// Append remaining page elements to the html element here.
// (the `head` and `body` elements may have been automatically created)
// You will need createElement and appendChild
createElement
appendChild
I'm gathering HTML from a HTML-editor and save in my database. I want to display this data to the user, but I don't know how to do this without the HTML-text being affected by the styling of my page.
Are there any cool libraries around which can help me with this, or is there a very simple way using only HTML tags and/or javascript?
The easiest way to do this is probably simply stuffing your HTML into an iframe.
Have a look at this question if you want to set it as HTML: Set content of iframe .
But I typically simply accept that the contents of the iframe are loaded using a separate request.
first i did my research on this topic after reading and applying so many JS i posting this problem,
i am trying to apply iframe in which i get content from some other domain.
i m trying to set the iframe height on the base of scrollheight of the content inside the iframe but failed to do so
i tried to use onload event of iframe but failed...
please help me i need to set the height of iframe dynamically by any mean necessary ..
if the code would be provided in Javascript that would be helpful to me
Thanks in advance
For security reasons, it is not possible to interact with a frame in a different domain.
That includes measuring its content.
#SLaks is correct. If the iframe content is on a different domain you cannot access its contents directly.
What you could do (and what I recently just did) is setup a proxy that pulls the content in via cURL (in php but im sure whatever server side language has something that is the equivalent). The iframe content is then on the same page and you can access the height of it via:
var _iframeHeight = $('#iframe').contents().find('body').height();
$('#iframe').height(_iframeHeight);
Also I forgot to mention (#SLaks thanks for the reminder) You would have to check all the script/style/image tags and check/add an absolute url to it. The proxy can get pretty tricky but it will get it done.
If you are able to alter the content inside the iframe, for example if you are the author or can contact the author of that iframe content, you can setup a double-iframe trick to send the height of the iframe to your main page.
Here is how that can be accomplished:
In your main page (AAA.com/mainpage.htm) you put an iframe (BBB.com/mainframe.htm).
Together with your main page, you create another page (AAA.com/heightproxy.htm)
You make that BBB.com/mainframe.htm would create an invisible iframe with AAA.com/heightproxy.htm inside.
Result: BBB.com/mainframe.htm on it's onload event can load it's iframe AAA.com/heightproxy.htm with some parameters added to URL. For example, it can put it's new height/width there into the parameters. Also, AAA.com/heightproxy.htm can access all JS function in AAA.com/mainpage.htm - as they are in same browser window and share same domain. This way it can redirect the width and height it received to the mainpage.
Disclaimer: This trick is only possible if you can modify the source of the iframe you need to include.
You cannot interact main page from iFrame if content is loaded from different URL (you can measure height from iframe, but cannot pass it to main page).
That can be overridden by loading content via simple proxy script.