How to inherit URL fragment from parent inside an `iframe` - html

I have a webpage with a "html reference manual", where I sent anchored URL links, e.g. like this:
http://www.vanillaware.de/plotFields/docs/html/plotFieldsDoc.html#prp/x
This opens automatically the page in the browser jumping to the referred anchor. This is the behavior I expect.
Now I want to embed this HTML page within another page using <iframe>, but still being able to send an URL link with an anchor. Unfortunately this doesn't work with this simple code:
<!DOCTYPE html>
<html>
<body>
<p><iframe src="plotFieldsDoc.html"></iframe></p>
</body>
</html>
Using a similar URL link as above:
http://www.vanillaware.de/plotFields/docs/html/tryUrlAnchor2.html#prp/x
Did I made something wrong and is there a simple way to reach my goal?

Use an inline onload event handler to reassign location.hash inside the iframe to match that of its parent page:
<!DOCTYPE html>
<html>
<body>
<p><iframe src="plotFieldsDoc.html" onload="this.contentDocument.location.hash=location.hash"></iframe></p>
</body>
</html>

Related

How to add image in HTML from a link?

I would like to add the image present at this link http://startup.registroimprese.it/isin/search?0-IResourceListener-data-resultRow-22-resultViewPnl-companyCardContainer-logoImg&antiCache=1628599295826 to my html page. Therefore, I have added the above URL to the "src" attribute in the < img> tag. My HTML code looks like this:
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<img src="http://startup.registroimprese.it/isin/search?0-IResourceListener-data-resultRow-26-resultViewPnl-companyCardContainer-logoImg&antiCache=1628599295828">
</body>
</html>
However, the image is not displayed when I render the page, and this is what I see.
blank page
What I expect to see instead, is the image at the link correctly displayed on my html page. Any idea what is wrong and how I could fix it?
NOTE: I know I could download the image locally and then add it, but I specifically need to find a solution to add the image from the link, and not from a path on my local computer.

onclick of a <a> tag, open in new tab another html file

When the tag is clicked, I want it to open another .html file (for example could be called discussions.html) in another tab.
<!DOCTYPE html>
<html>
<head>
<body>
open new html file
</body>
</head>
</html>
You just have to set the target of the link to blank, that's all.
See below:
<html>
<head>
<body>
DISCUSSIONS
</body>
</head>
</html>
If you want to open link in a new tab:
some text
Or for page in your domain:
some text
You would want to put a link inside there ^^
e.g. /dist/discussion.html" if you want to make it point on another one of your websites
in this project
or http://google.com if you want it to redirect to another existing site

Why doesn't the src attribute of an iframe change if I click on any link inside it?

In the following code the src attribute of iframe always shows b.html in devtools insepct, even after clicking on the link in the b.html page
index.html
<html>
<body>
<iframe src="b.html">
</iframe>
</body>
</html>
b.html
<html>
<body>
link
</body>
</html>
d.html
<html>
</html>
The spec doesn't appear to explain why this is the case, other than by stating that the WindowProxy operates independently of the element itself (for what it's worth). It does confirm that this is expected behavior (W3C HTML5, WHATWG HTML):
If the user navigates away from this page, the iframe’s corresponding WindowProxy object will proxy new Window objects for new Document objects, but the src attribute will not change.
As #BoltClock said, the src= attribute of the iframe doesn't change but you can get the new url of the iframe by accessing its
document.getElementById('my-iframe').contentWindow.location.href
but your iframe has to be on the same domain as the page hosting it.

How can an HTML be contained, inline, within another HTML doc?

Is it possible wrap an HTML document within another, all within the same file? Such as:
<!DOCTYPE html>
<html>
<body>
...
<!DOCTYPE html>
<html>
<body>...</body>
</html>
...
</html>
Why would I want to do that, you ask? (I don't :-) ) The phpinfo() function in PHP generates a full HTML document (to be used as a single call, on its own). I created an HTML document around it. Most browsers display this as I expected, but it is invalid HTML.
<!DOCTYPE html>
<html>
<body>
<h1>PHP Info</H1>
<?php phpinfo(); ?>
</body>
</html>
I can solve this with PHP, but I was for an HTML-only solution; something like:
...
<xframe>
<!DOCTYPE html>
<html>
<body>...</body>
</html>
</xframe>
...
I.e., something like <iframe> without the external reference.
Not as such.
The closest you could come would be to use an iframe with the src expressed as a data: scheme URL (which encodes the entire HTML document inside the URL itself) … but that would require phpinfo() to return a string of HTML instead of just outputting it.

html doesn't show in browser

I need to figure out what makes the html code in this page doesn't show in browser.
http://arbsq.net/dev/out_html.htm
I checked with:
http://validator.w3.org/check?uri=http%3A%2F%2Farbsq.net%2Fdev%2Fout_html.htm&charset=%28detect+automatically%29&doctype=Inline&group=0
But it is not clear to me what causes the browser not to process the html code
Remove the <title/> tag. The browser is interpreting your entire html code as the title of the page.
Remove <title/> or change to <title>Site title</title> otherwise the hole site is interpreted as your title.
You need to move the contents of your <title></title> tag to the <body></body> tag. If you just remove the <title></title> tag like others have suggested, it will still not show because tags in the <head></head> tag are invisible to the end user. The <head></head> tag contains scripts and links to external resources as well as information about the page for the browser. The <body></body> tag should contain all of your HTML markup for the page.