Alternatives To IFrame Tag In HTML? - QA With Experts
Có thể bạn quan tâm

- Ask a question
- Contribute an article
- Questions
- Articles
- Register
- Log in
- C#
- ASP.NET
- C/C++
- JAVA
- Javascript
- jQuery
- HTML
- CSS
- SQL
- Categories
- Tools
I would like to know what are the possible alternatives to iFrame, inside which I can inject Coss domain html(without iframe)? Or you can say I want to show HTML page without using iFrame in a Div
Asked by:- pika1 : 10922 At:- 2/23/2018 7:23:37 AMHTML iframe alternative embed web page without iframe Commentadd comment to question3 Answers
Answered by:- jonAlthough is not equivalent of iFrame but you can use these :
1. you can use <embed> element<embed id="123" src="http://google.com" />
works fine in chrome ,safari and firefox, to make it work in firefox, you need wrap it with object<object data="url" type=text/html> <embed src="url" id=123> </embed> </object>
2. Another way is to Use AJAX call and load the URL into div , like below example$("#area").load("example.html #content");
That finds the content in the file example.html within the element with an ID of contentand puts it on to the current page, inside the element with an ID of area.
3. HTML Imports
You can import external HTML file<!-- Resources on other origins must be CORS-enabled. --> <link rel="import" href="http://somedomain.com/elements.html">
In this way, you can also divide HTML components and re-use same html code.
3 At:- 2/23/2018 8:52:19 AM Updated at:- 10/6/2022 6:52:27 AM Comment comment to above answer
Answered by:- VinnuContent inside iFrame is not indexed by Google and hence no good for SEO, so to avoid it best solution will be jQuery method like below <div id='include-from-outside'></div> <script type='text/javascript'> $('#include-from-outside').load('http://example.com/included.html'); </script>
This will include paste html from url http://example.com/included.html inside div with id='include-from-outside'
3 At:- 2/23/2018 4:03:21 PM Comment comment to above answer
Answered by:- vikas_jkI would like to add one more way, since "HTML Import" is obsolete now in most of the major browsers, you can use Javascript's "fetch" to get external HTML into the page.
This can be the example of itclass SampleComponent extends HTMLElement { async connectedCallback() { let res = await fetch( 'your-component.html' ) this.innerHTML = await res.text() } } customElements.define('your-component', SampleComponent)
Since, 'fetch' is an asynchronous function so you will have to use async/await or Promises, as shown above, thanks
0 At:- 9/28/2020 1:48:53 PM Comment comment to above answerRelated Articles
41346 Things to improve your google ranking using simple SEO tips4952Importance of Structuring URLs for SEO9162Export html table to excel using jQuery / Javascript10803How to get user location using Javascript / HTML5 Geolocation?4687Implementing Javascript Drag and Drop using HTML5Subscribe Now
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly
Related Questions
5257confirmation box on span using jquery6833how to check which select option group is selected using jquery19261Child li dorpdown is not covering width as parent li in navigation5018how to find if specific element exists in html6707how to interchange position of two divs on mobileFollow usTừ khóa » Html5 Alternative To Iframe
-
Alternatives Of Iframe In HTML - Delft Stack
-
Alternative To IFrames With HTML5 - Stack Overflow
-
Alternative To IFrames In HTML5 - GeeksforGeeks
-
What Is An Alternative To IFrame With HTML5? - Quora
-
From Object To Iframe — Other Embedding Technologies
-
4 Iframe Alternatives For Better Content Optimisation - Return
-
Alternative Way For Iframe In Html 5 - CodeProject
-
HTML Iframe Tag - W3Schools
-
Alternative For Frames In Html5 Using Iframes
-
Alternatives To HTML5 Iframe Srcdoc? - Tutorialspoint
-
Is Their Any Alternative To HTML5 Iframe Srcdoc? - Tutorialspoint
-
Alternative To Iframe For External Website
-
Alternative To Iframes With Html5 - ADocLib
-
Javascript – Alternative To Iframe - ITecNote