Open URL in a new tab/window with CGI [duplicate] - cgi

For a banner management system i use a
header("Location: http://www.awebsite.com");
to redirect to the proper website. Is it possible to force this header script to open in a new window?

<a href='yourbannerscript.php' target='_blank'>...</a>

No. If you want a new window, you have to deliver the redirect as HTML/Javascript.

This works for me
echo "<script>window.open('yoursite.com');</script>";

It would be nasty, and might not be want you want, but including an IFRAME tag pointing to a php file with the header redirect could be a solution. Doesn't create a new window, but creates a window-within-a-window.
<iframe src="/myredirectscript.php"></iframe>

You should redirect to a page with a redirect metà tag like the one on the most voted answer at Open HTML meta redirect in new window
So the page you redirect your headers to will contain a metà tag with:
<meta http-equiv="refresh" />
<meta content="0; URL=javascript:window.open('http://uri.of
.your.pagewhereyouwabtoredirect/path','_parent');"/>

It's Not possible.. Instead of that you can set open new tab in form attribute target="_blank"
<form target="_blank" method="post" action="contact-function.php">

Related

Shopify add new index.html page with url https://myshopifyshop/index.html

I am working with external tracking service. They sent my index.html file, which looks like this:
<html>
<head>
<!-- tag -->
<script type="text/javascript" src="//path.js"></script>
</head>
<body>
</body>
</html>
They want us to upload this file to shopify and sent them the url to it. The url should look like this https://myshopifyshop/index.html. I couldn't find any article how to upload or create new blank html page with .html extension. Is this somehow possible?
You can't create an html page that will follow the root url of your site.
But you can upload a html page as an asset and link that asset as a page.
Example url will be:
https://cdn.shopify.com/s/files/1/*****/*****/t/4/assets/index.html
But I don't think that this will do you any good, since tracking services requires you to track the current site and not a dummy file that no one will ever open.
It's highly possible that the only important part is the script and everything else is not needed.
So you actually may need to add the script in your layout/theme.liquid file and ignore the rest.
Please contact the the tracking service and let them know that you are not using a static HTML site, but a Shopify one and what steps should you follow.

How to implement Canonical Tag in Pimcore CMS?

I have to implement canonical tags on a customer website which works with Pimcore CMS. Does somebody has experience with that or can give me some hints?
A way could be to set a Document Property and render it in your view.
see: https://pimcore.com/docs/4.6.x/Development_Documentation/Tools_and_Features/Properties.html
For PHP Templating Engine you could add this line and set it properly in your Backend.
<link rel="canonical" href="<?= $this->document->getProperty('canonicalHref');?>" />
If you want to set this tag globally, or with some simple url regex matching, you can do it straight from the admin panel using Marketing > Tag & Snippet Management.
To allow a user to customize URL you can create the predefined property 'canonicalHref',
then put in layout twig file:
<head>
....
{% set canonicalUrl = document.getProperty('canonicalHref')|default(app.request.getUri??'') %}
<link rel="canonical" href="{{ canonicalUrl }}"/>
</head>
You will still need:
to customize HTTP headers in PDF files generated for the print version
and to add 301 redirects from HTTP to HTTPS version.

How to redirect to the page on another domain with 'a' tag in Vue js project?

I have an ordinary link to another page in my HTML:
<a href='facebook.com'>
or
<a href='www.facebook.com'>
When I click on it, its redirects me to:
my-domen.dev/facebook.com
How to redirect correctly to page on another domain?
You need to specify the protocol if you are attempting to trying to load an external URL.
<p>Right click and open links in a new tab.</p>
Internal - Will throw 404 - facebook.com<br>
Internal - Will throw 404 - www.facebook.com<br>
External - https://facebook.com<br>
You can read more about it here: Why does an anchor tag's href values need http:// preprended to the URL?

Can't access iframe of different origin in the parent jsp

Quick example for the kind of functionality required (just for exampple):
http://www.indeed.hk/cmp/Calvin-Klein-Jeans-&-Calvin-Klein-Underwear/jobs/Part-Time-Sales-Associate-1643e24903d9f4c7
If you click on apply-now button, it shows an iframe.
I am having a project where I am trying to access an iframe of different origin, say https: //subdomain.example.com, on a jsp page of origin say http://www.example.com but it gives me the following error:
Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin http://www.example.com from accessing a frame with origin https://subdomain.example.com. The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "https". Protocols must match.
Lets call the parent jsp page as parent.jsp, and the iframe jsp as iframe.jsp.
parent.jsp is on server S, and the project name is xyznet
iframe.jsp is on server R, and the project name is xyz
Here is a piece of code from the parent.jsp
<%
java.util.Map model = (java.util.Map)pageContext.findAttribute("model");
%>
<html>
<body>
<h1> This is the parent page
<iframe id="quick-apply-frame" name="iframe-name" src=" <%=https: //sub.domain.com/apply.html?ref=${model.x.y}" onload="quickSetParams();">
</iframe>
<script>
function quickSetParams() {
$("[name=iframe-name]").contents().find("[name=iframe-param-name]").val(${model.value1}');
}
</body>
</html>
And here is piece of code from the iframe.jsp
<html>
<body>
<form action="xyz.html">
<input name="iframe-parm-name" value=""/>
<input name="iframe-parm-name2" value="${model.parm2}" />
</form>
</body>
</html>
Handler which loads the iframe.jsp is a SimpleFormController, located on server R
I have come across some solutions where the data is transferred directly using javascript, but I need a handler for this, and so, a direct javascript redirect or nesting of iframes would not work for me
Thanks James for some leads. I finally got it working!
I still dont completely understand how it works, but here is what I did:
I dont load the iframe.jsp (located in https: //sub.domain.com) at the same time as the parent.jsp is loaded. Means, the src of the iframe is not set initially.
Instead, I call a javascript function to load the iframe once the "showIframe" button in the parent is clicked. I got a suggestion from someone that to crack cross domain security issue, you have to set the src of the iframe via javascript after the page loads.
Some more pointers other can explore is CORS, where you add a parameter like this in your ssl.conf or httpd.conf (apache configuration)
Header set Access-Control-Allow-Origin "http://www.domain.com" . It basically grants permission to access to the domain mentioned

How to hide robot.txt from vistors?

I have seen sites hide the robot.txt file.
if you enter the name of the site as
http://www.mysite.com/robot.txt
you will not receive the robot.txt,
I also want to hide the file robot.txt from visitors how to do it?
Is there a connection of these lines
<meta name="ROBOTS" content="NOODP">
         <meta name="Slurp" content="NOYDIR">
So I do not understand the meaning of the code.
Thank you!
I'm not sure exactly what you're asking, but couldn't you do that with URL rewrites? You might be able to display the robots.txt file for visitors with the User Agent strings of a crawler (for instance, "Googlebot"), and then redirect to a 404 if it's a non-crawler UA