0
Is it possible to type in a web url and display it on an element in the page?
I am doing an html project. What I wanted is create a page with a display area where the website to be searched can be viewed. As in a web browser- typing in the url and display it. First the user types in a url and then the webpage is showed on the screen and not in the browser. This project is somewhat similar to a browser.
6 Respuestas
+ 3
iframe
document.getElementsByTagName("iframe")[0].src = document.getElementsByTagName("input")[0].value;
https://code.sololearn.com/WAI9PAU3Nz90/?ref=app
+ 2
Carefully look at this:
getElementById
getElementsByTagName
getElementsByClassName
What's in common?
What's the difference ?
first get 'element' (singular), seconds get 'elements' (plural)...
The first return a single element, while both two others return an array-like list of elements (nodes collections): you must access elements from the collection by an index ;)
So the fix is: replace getElementsByTagName() by getElementsByTagName()[0] (in left and right hand of the assignation of input value to iframe src in your onclick event handler ;)
+ 2
You may find answer in https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/url.
+ 2
🤗
+ 1
Be aware that some websites prevents to use their pages not at the top level window (embeded in another domain) ^^
0
Thanks.
is it possible to use it with python?