Open HTML meta redirect in new window - html

I need web page to redirect via HTML meta and open that page in a new window. How can I do that?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Photo Gallery Redirect</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Refresh" content="0; url=http://google.com">
</head>
<body>
</body>
</html>

You can do this! It is particularly useful when the refresh is being run in an iframe (such as a Facebook app canvas page), and you want the refresh to load the content to the main (parent) window.
Use the following Javascript in your meta-redirect:
<meta http-equiv="refresh" content="5; URL=javascript:window.open('http://google.com','_parent');">

You can't do that with a meta redirect. Grab JavaScript.
<script type="text/javascript">window.open('http://google.com');</script>
Either that, or add target="_blank" to the originating link/form which landed in this "Photo Gallery Redirect" page.
click here
or
<form action="http://google.com" target="_blank">
<input type="submit" />
</form>
Not XHTML/HTML5 valid, but it works. Else you can just add rel="ext" and use some piece of Javascript to silently put the target="_blank" in anyway.

You can't. You need to use javascript on a timer to open a popup (which most likely will be blocked by some browsers as an unrequested popup window)
You are probably better off taking a different approach to your problem.

make it without using url attribute just like this
<meta http-equiv="refresh" content="5;https://stackoverflow.com">

Related

Removing <body> with a userscript

I'm sorry, but I am not very good with programming. I am trying to fix this irritating bug on my school's website through a userscript. I have tested the RegEx on several pages, at least that works. I need to make the userscript remove the parts I don't want to see. This is a snippet from the source of the website, I have marked what needs to be removed with '//'.
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
//<html><head>
//<title>404 Not Found</title>
//</head><body>
//<h1>Not Found</h1>
//<p>The requested URL /get.php was not found on this server.</p>
//</body></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" >
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="robots" content="index, follow" />
This is my userscript that does not work. I know it reflects my skills as a programmer, please don't hate.
var REGEX = /<HTML>(.*?)([^\n]*?\n+?)+?<\/BODY><\/HTML>/ig;
document.body.innerHTML=document.body.innerHTML.replace(REGEX, '');
This markup is obviously invalid, but the browser (at least Chrome and Firefox) will merge these two <html> sections together with its best guess. So interacting with document.body is probably not what you want.
Doing something like this will visually fix the issue:
document.querySelector('h1').remove() // remove first h1 "Not Found"
document.querySelector('p').remove() // remove first p "The requested..."

SEO issue with redirecting users to a mobile site

Will using the following code, give me some SEO problems? My Google rank dropped when I started using it.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="refresh" content="0;document.location" />
</head>
<body>
<p></p>
<!--?xml version="1.0" encoding="UTF-8"?-->
<p><link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /></p>
<title></title>
<script language="javascript" type="text/javascript">// <![CDATA[
if (screen.width <= 699) {
document.location = "http://mobilesite";
}
else{
document.location.href = "http://desktopsite"
}
// ]]></script>
</body>
</html>
I think you need to learn HTML structuring first and foremost.
The favicon include and title should always be in the <head> containment.
Not sure why you have an XML declaration in their either.
You might as well use the HTML5 doctype as well <!doctype html>.
Regarding the SEO issue. Content is king. Search engines mainly go on content contained within the page. Now I'm not sure how your JS will affect this as the spiders and robots that crawl the page don't run JavaScript (I could be wrong, hopefully someone will correct me if that's the case).

External Images does not display when used in img tag

I have these strange image urls that if I call direct in browser, an image shows up but when I use it in an img tag no image shows up.
http://thetvdb.com/banners/_cache/fanart/original/248951-1.jpg
I'm sure I'm making some silly mistake. Here is simple code.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org
/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title></title>
</head>
<body>
<img src="http://thetvdb.com/banners/_cache/fanart/original/248951-1.jpg" alt=""/>
</body>
</html>
Any help?
The TV DB does not want to use their bandwidth to display an image on your site.
We don't allow any kind of hotlinking, you are only allowed to directly download the images and then use them as you see fit, you may not use us as a host.
They have taken steps to prevent you from doing this.
quentin#laptop:~ # curl -e http://example.com/ http://thetvdb.com/banners/_cache/fanart/original/248951-1.jpg
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx</center>
</body>
</html>

A simple HTML page with content, but get blank page in Chrome 6.0.472.53

I am developing a ASP.Net web site and my page works normally in IE/Firefox/Opera
This is the page source code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
Content Navigation
</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" type="text/javascript" src="/js/jquery/jquery-1.4.2.min.js"></script>
</head>
<body>
dd222222222222222222222
<div id="content-tree">
</div>
</body>
</html>
It is simple, isn't it? But in my Chrome 6.0.472.53, I always get a blank page, just a blank page, nothing else.
After click the "Inspect Element" in context menu, here is the HTML DOM structure I see
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>
Content Navigation
</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="javascript" type="text/javascript" src="/js/jquery/jquery-1.4.2.min.js"></script></head></html>
Hmmm, the body is gone!
If I remove the jquery js reference line, body comes back
Is this a bug in Chrome or mine? my web host is IIS7.1
Thank you for any help
Update:
I have reported this issue to Chrome Help
And here is the screenshot:
Correct: http://img128.picfoco.com/img.php?id=1274578614&q=&jump=5176678858&ru=
Incorrect: http://img122.picfoco.com/img.php?id=778329008&q=&jump=4680429165&ru=
Not really sure, I can't replicate the issue in my Chrome build. Can you try replacing your jQuery ref to the following from the Google repository? If it does the same, possibly try degrading to 1.3 and see if that produces the same results.
<script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" ></script>
I find the reason now
because there is a "Connection:Close" in the response HTTP HEAD, and it only affects Chrome
After remove this head, everything is fine

Multiple Html <head> in the browser , caused by DreamWeaver bom

I am using DreamWeaver to code xHtml docs. in the program the code is valid but when I upload it in the inspect element I see double <head> tags and when I right-click to see the source file it seems o.k.
Is it because I'm using dreamweaver? what can be wrong?
the first error is : "Extra <html> encountered. Migrating attributes back to the original <html> element and ignoring the tag." - in line 3
The code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="the content of my doc" />
<meta name="description" content="this is an example document" />
<link rel="alternate" type="application/rss+xml" title="rss feeds" href="linkto/xml/feeds.xml" />
<!-- scripts -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<title>The Title</title>
</head>
<body>
<!-- content -->
</body>
</html>
Thank you very much.
No problem in Chromium 5.0.307.9 (Developer Build 39052) under Linux. I can't test it in Safari now.
EDIT: Proposed test case had nothing to do with this problem, neither could see any extra <head> tags. However, I looked at the Developer Tools of Safari and Chrome under Windows and Firebug in Firefox and all three rendered the DOM incorrectly. Just have a look at this picture and see that the first <link> tag has jumped into the body.
This problem also has nothing to do with Javascript because when turning off Javascript the result is the same, even more clear when comparing with the source code. Strange I didn't notice this under Linux.
The Developer Tools of the WebKit browsers give an even clearer picture (also notice the jQuery error message). I suspect the Unicode Byte-Order Mark (BOM) at the beginning of the file causing the problem: as you can see the BOM is moved to the <body> of the document, perhaps dragging several elements in the <head> with it. But also the unclosed <link> elements, as shown by the W3C validator, might give some issues, although browsers usually handle this without any problems. First get rid of the BOM in your file and see if the problem persists.
And I see another error: those tags beginning with <meta ... are called meta tags, not "meat tags". ;-)
You should have a title element what you write between
the <title></title> tags will been displayed in top bar of your browser
Just make sure your
</head>
tag has the slash in the actual file you're working on. That's an easy typo.
To remove BOM from your document, you can use this php function:
function removeBOM($str=""){
if(substr($str, 0,3) == pack("CCC",0xef,0xbb,0xbf)) {
$str=substr($str, 3);
}
return $str;}