HTML URL Variable Substitutions not working when user opens link in new window
See original GitHub issueWhat’s the issue?
We are trying to use variable substitution in links as documented here.
Here is an example of the HTML we are using:
<a href="//example.com/?SRC=QUERY_PARAM(SRC,XXXX)" data-amp-replace="QUERY_PARAM">Go to my site</a>
This is working fine if you click on the link normally, but we have noticed that if we right-click on one of these links, or press down on a mobile device to open in a new window, the variable substitution does not work correctly. Instead of linking to //example.com?SRC=XXXX
we get //example.com?SRC=QUERY_PARAM(SRC,E132)
.
How do we reproduce the issue?
Here is a link to the test case - http://jsbin.com/daduzekiho/edit?html,output
- Click on the link normally to observe the variable substitution working correctly
- Go back to the test case and right-click/press and hold on the link and open in a new tab/window. Observe that the variable has not been substituted.
What browsers are affected?
Seems to affect all browsers. We have observed this behaviour in Chrome, Safari, Firefox and Microsoft Edge.
Which AMP version is affected?
Version 1524089272632
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top Results From Across the Web
URL Link Substitution using Variables
Assume we have a variable called my_url, which is the URL of a web page or document file. The examples below are the...
Read more >Open a URL in a new tab (and not a new window)
This is a trick, function openInNewTab(url) { window.open(url, '_blank').focus(); } // Or just window.open(url, '_blank').focus();.
Read more ><input type="url"> - HTML: HyperText Markup Language | MDN
A single properly-formed absolute URL. This doesn't necessarily mean the URL address exists, but it is at least formatted correctly. In simple ...
Read more >URL Canonicalization and the Canonical Tag
A canonical URL is the URL of the page that Google thinks is most representative from a set of duplicate pages on your...
Read more >Query string - Wikipedia
A query string is a part of a uniform resource locator (URL) that assigns values to specified parameters. A query string commonly includes...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Right click takes a different path in the browser, it doesn’t fire the click event handler so we never do the substitution. May be fixable by catching right click events, stashing the original url somewhere and updating the href url in place.
That’s great @alabiaga, thanks for letting me know!