Wordpress theme blocks target=“_blank” on links. How do I reactivate it for some external links?Wordpress navbar links using href=“#” not working as a dummy linkLink to custom php theme page in wordpresswhen i use link target _blank then onClick new tab open and suddenly tab again closeopen all links on post in new tab , target=“_blank”Adding attribute 'href' of existing links to other links with Jqueryhref=“javascript:” open in new tabHow would i make this php link _blank?HTML embedded PDF all links override to open in a new tab (target=“_blank”)How to detect whether a link clicked should be opened in same UIWebview or external?Wordpress menu links not working with left clickWebsite doesn't load portfolio content on mobile
The equation of motion for a scalar field in curved spacetime in terms of the covariant derivative
Confused about the answers to two logic problems
Wherein the Shatapatha Brahmana it was mentioned about 8.64 lakh alphabets in Vedas?
Bitcoin successfully deducted on sender wallet but did not reach receiver wallet
Am I overreacting to my team leader's unethical requests?
Is Texas Instrument wrong with their pin number on TO-92 package?
English - Acceptable use of parentheses in an author's name
What does "sardine box" mean?
Double redundancy for the Saturn V LVDC computer memory, how were disagreements resolved?
What is the difference between 型 and 形?
How to create all combinations from a nested list while preserving the structure using R?
During the Space Shuttle Columbia Disaster of 2003, Why Did The Flight Director Say, "Lock the doors."?
Three legged NOT gate? What is this symbol?
Should I ask for permission to write an expository post about someone's else research?
Why do oscilloscopes use SMPSes instead of linear power supplies?
How can you evade tax by getting employment income just in equity, then using this equity as collateral to take out loan?
Ex-contractor published company source code and secrets online
Is refreshing multiple times a test case for web applications?
Not going forward with internship interview process
Blocking people from taking pictures of me with smartphone
How can I solve for the intersection points of two ellipses?
Y2K... in 2019?
A tool to replace all words with antonyms
Simple Stop watch which i want to extend
Wordpress theme blocks target=“_blank” on links. How do I reactivate it for some external links?
Wordpress navbar links using href=“#” not working as a dummy linkLink to custom php theme page in wordpresswhen i use link target _blank then onClick new tab open and suddenly tab again closeopen all links on post in new tab , target=“_blank”Adding attribute 'href' of existing links to other links with Jqueryhref=“javascript:” open in new tabHow would i make this php link _blank?HTML embedded PDF all links override to open in a new tab (target=“_blank”)How to detect whether a link clicked should be opened in same UIWebview or external?Wordpress menu links not working with left clickWebsite doesn't load portfolio content on mobile
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm building a photography portfolio website on Wordpress using this theme: http://wpshower.com/themes/expositio/ . The theme hasn't been updated in years but still works smoothly. I have an issue with assigning target="_blank" to some external links though. The option is there but it has no effect whatsoever.
I've looked for advice and have tried every available plugin that addresses the problem, with the best result being opening the external link in both a new tab and the current tab.
I've looked into all the theme files, they are not many, and thinking that this is a javascript issue, I have identified the following code. It deals with the mobile menu animations but it's the only mention of links.
It was also discussed in a similar thread in here: Wordpress navbar links using href="#" not working as a dummy link
$('a').on('click', function(e) {
e.preventDefault();
var _this = $(this);
// close mobile menu if it's open, redirect otherwise
if (_body.hasClass('toggled-on') && _this.parents('#page').length == 1
&& _this.parents('#primary-navigation').length == 0
)
load_effect.menuOff();
else
load_effect.loader.show();
var href = $(this).attr('href');
$('.site').css('opacity', 0);
setTimeout(function()
window.location = href;
, load_effect.duration);
Finally, here is website using the same theme where the external links do open in a new tab: http://www.tokyogoodidea.com/
I'd be grateful for any advice on solving this little glitch. I'm not good at all with js and don't know what to change.
Here's my project's link: http://one.clrblnd.com/
Thanks in advance.
javascript wordpress href
add a comment |
I'm building a photography portfolio website on Wordpress using this theme: http://wpshower.com/themes/expositio/ . The theme hasn't been updated in years but still works smoothly. I have an issue with assigning target="_blank" to some external links though. The option is there but it has no effect whatsoever.
I've looked for advice and have tried every available plugin that addresses the problem, with the best result being opening the external link in both a new tab and the current tab.
I've looked into all the theme files, they are not many, and thinking that this is a javascript issue, I have identified the following code. It deals with the mobile menu animations but it's the only mention of links.
It was also discussed in a similar thread in here: Wordpress navbar links using href="#" not working as a dummy link
$('a').on('click', function(e) {
e.preventDefault();
var _this = $(this);
// close mobile menu if it's open, redirect otherwise
if (_body.hasClass('toggled-on') && _this.parents('#page').length == 1
&& _this.parents('#primary-navigation').length == 0
)
load_effect.menuOff();
else
load_effect.loader.show();
var href = $(this).attr('href');
$('.site').css('opacity', 0);
setTimeout(function()
window.location = href;
, load_effect.duration);
Finally, here is website using the same theme where the external links do open in a new tab: http://www.tokyogoodidea.com/
I'd be grateful for any advice on solving this little glitch. I'm not good at all with js and don't know what to change.
Here's my project's link: http://one.clrblnd.com/
Thanks in advance.
javascript wordpress href
add a comment |
I'm building a photography portfolio website on Wordpress using this theme: http://wpshower.com/themes/expositio/ . The theme hasn't been updated in years but still works smoothly. I have an issue with assigning target="_blank" to some external links though. The option is there but it has no effect whatsoever.
I've looked for advice and have tried every available plugin that addresses the problem, with the best result being opening the external link in both a new tab and the current tab.
I've looked into all the theme files, they are not many, and thinking that this is a javascript issue, I have identified the following code. It deals with the mobile menu animations but it's the only mention of links.
It was also discussed in a similar thread in here: Wordpress navbar links using href="#" not working as a dummy link
$('a').on('click', function(e) {
e.preventDefault();
var _this = $(this);
// close mobile menu if it's open, redirect otherwise
if (_body.hasClass('toggled-on') && _this.parents('#page').length == 1
&& _this.parents('#primary-navigation').length == 0
)
load_effect.menuOff();
else
load_effect.loader.show();
var href = $(this).attr('href');
$('.site').css('opacity', 0);
setTimeout(function()
window.location = href;
, load_effect.duration);
Finally, here is website using the same theme where the external links do open in a new tab: http://www.tokyogoodidea.com/
I'd be grateful for any advice on solving this little glitch. I'm not good at all with js and don't know what to change.
Here's my project's link: http://one.clrblnd.com/
Thanks in advance.
javascript wordpress href
I'm building a photography portfolio website on Wordpress using this theme: http://wpshower.com/themes/expositio/ . The theme hasn't been updated in years but still works smoothly. I have an issue with assigning target="_blank" to some external links though. The option is there but it has no effect whatsoever.
I've looked for advice and have tried every available plugin that addresses the problem, with the best result being opening the external link in both a new tab and the current tab.
I've looked into all the theme files, they are not many, and thinking that this is a javascript issue, I have identified the following code. It deals with the mobile menu animations but it's the only mention of links.
It was also discussed in a similar thread in here: Wordpress navbar links using href="#" not working as a dummy link
$('a').on('click', function(e) {
e.preventDefault();
var _this = $(this);
// close mobile menu if it's open, redirect otherwise
if (_body.hasClass('toggled-on') && _this.parents('#page').length == 1
&& _this.parents('#primary-navigation').length == 0
)
load_effect.menuOff();
else
load_effect.loader.show();
var href = $(this).attr('href');
$('.site').css('opacity', 0);
setTimeout(function()
window.location = href;
, load_effect.duration);
Finally, here is website using the same theme where the external links do open in a new tab: http://www.tokyogoodidea.com/
I'd be grateful for any advice on solving this little glitch. I'm not good at all with js and don't know what to change.
Here's my project's link: http://one.clrblnd.com/
Thanks in advance.
javascript wordpress href
javascript wordpress href
asked Mar 27 at 8:36
JohnPitsJohnPits
31 bronze badge
31 bronze badge
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
There seems to be no reliable way to open a new tab in Javascript (a quick search tells it could be tricky), and the code indeeed looks like it is blocking a new page being opened. You can probably try if this works.
Firstly after this line
var href = $(this).attr('href');
add another line that says (this line gets the value of target
attribute/properties from the tag, and assumed to be _self
if undefined)
var target = $(this).prop('target') || '_self';
Then look for this line
$('.site').css('opacity', 0);
What it does is to make the whole page blank essentially. You may want to do something with this, for example wrap it in a if statement so it doesn't execute when target="_blank"
. A quick way to fix it is by replacing it to
target === '_blank' || $('.site').css('opacity', 0);
Next replace (just a few lines after the previous one)
window.location = href;
with
window.open(href, target)
The respective block should look like
load_effect.loader.show();
var href = $(this).attr('href');
var target = $(this).prop('target') || '_self';
target === '_blank' || $('.site').css('opacity', 0);
setTimeout(function()
window.open(href, target)
, load_effect.duration);
This is asuming window.open
works as expected (documentation is here). What happens in the code is that the author stopped the default behavior after clicking a link with
e.preventDefault();
in order to allow some fancy animation to complete before the browser proceeds to load the intended page. However by simplifying the page load with
window.location = href;
it ignores the target attribute/property of the respective <a />
tag.
Thanks or the reply @Jeffrey04 ! It worked but a new issue manifests. The link does indeed open in a new tab but the original tab is going blank. The URL remains the same but the content disappeared and reappears on refreshing. If you click on the Instagram link on the main menu at link you'll see what I mean.
– JohnPits
Mar 27 at 10:11
edited, but still doesn't seem to fix your problem, sorry i suppose that's all I can help for now
– Jeffrey04
Mar 27 at 11:07
It worked! Thanks a million, @Jeffrey04 !
– JohnPits
Mar 27 at 11:34
likely won't work in all browsers tho
– Jeffrey04
Mar 27 at 11:56
might also depend on if you a pop-up blocker installed. Think some browsers have this facility built-in.
– Loren Rosen
Mar 27 at 16:51
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372821%2fwordpress-theme-blocks-target-blank-on-links-how-do-i-reactivate-it-for-some%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
There seems to be no reliable way to open a new tab in Javascript (a quick search tells it could be tricky), and the code indeeed looks like it is blocking a new page being opened. You can probably try if this works.
Firstly after this line
var href = $(this).attr('href');
add another line that says (this line gets the value of target
attribute/properties from the tag, and assumed to be _self
if undefined)
var target = $(this).prop('target') || '_self';
Then look for this line
$('.site').css('opacity', 0);
What it does is to make the whole page blank essentially. You may want to do something with this, for example wrap it in a if statement so it doesn't execute when target="_blank"
. A quick way to fix it is by replacing it to
target === '_blank' || $('.site').css('opacity', 0);
Next replace (just a few lines after the previous one)
window.location = href;
with
window.open(href, target)
The respective block should look like
load_effect.loader.show();
var href = $(this).attr('href');
var target = $(this).prop('target') || '_self';
target === '_blank' || $('.site').css('opacity', 0);
setTimeout(function()
window.open(href, target)
, load_effect.duration);
This is asuming window.open
works as expected (documentation is here). What happens in the code is that the author stopped the default behavior after clicking a link with
e.preventDefault();
in order to allow some fancy animation to complete before the browser proceeds to load the intended page. However by simplifying the page load with
window.location = href;
it ignores the target attribute/property of the respective <a />
tag.
Thanks or the reply @Jeffrey04 ! It worked but a new issue manifests. The link does indeed open in a new tab but the original tab is going blank. The URL remains the same but the content disappeared and reappears on refreshing. If you click on the Instagram link on the main menu at link you'll see what I mean.
– JohnPits
Mar 27 at 10:11
edited, but still doesn't seem to fix your problem, sorry i suppose that's all I can help for now
– Jeffrey04
Mar 27 at 11:07
It worked! Thanks a million, @Jeffrey04 !
– JohnPits
Mar 27 at 11:34
likely won't work in all browsers tho
– Jeffrey04
Mar 27 at 11:56
might also depend on if you a pop-up blocker installed. Think some browsers have this facility built-in.
– Loren Rosen
Mar 27 at 16:51
|
show 1 more comment
There seems to be no reliable way to open a new tab in Javascript (a quick search tells it could be tricky), and the code indeeed looks like it is blocking a new page being opened. You can probably try if this works.
Firstly after this line
var href = $(this).attr('href');
add another line that says (this line gets the value of target
attribute/properties from the tag, and assumed to be _self
if undefined)
var target = $(this).prop('target') || '_self';
Then look for this line
$('.site').css('opacity', 0);
What it does is to make the whole page blank essentially. You may want to do something with this, for example wrap it in a if statement so it doesn't execute when target="_blank"
. A quick way to fix it is by replacing it to
target === '_blank' || $('.site').css('opacity', 0);
Next replace (just a few lines after the previous one)
window.location = href;
with
window.open(href, target)
The respective block should look like
load_effect.loader.show();
var href = $(this).attr('href');
var target = $(this).prop('target') || '_self';
target === '_blank' || $('.site').css('opacity', 0);
setTimeout(function()
window.open(href, target)
, load_effect.duration);
This is asuming window.open
works as expected (documentation is here). What happens in the code is that the author stopped the default behavior after clicking a link with
e.preventDefault();
in order to allow some fancy animation to complete before the browser proceeds to load the intended page. However by simplifying the page load with
window.location = href;
it ignores the target attribute/property of the respective <a />
tag.
Thanks or the reply @Jeffrey04 ! It worked but a new issue manifests. The link does indeed open in a new tab but the original tab is going blank. The URL remains the same but the content disappeared and reappears on refreshing. If you click on the Instagram link on the main menu at link you'll see what I mean.
– JohnPits
Mar 27 at 10:11
edited, but still doesn't seem to fix your problem, sorry i suppose that's all I can help for now
– Jeffrey04
Mar 27 at 11:07
It worked! Thanks a million, @Jeffrey04 !
– JohnPits
Mar 27 at 11:34
likely won't work in all browsers tho
– Jeffrey04
Mar 27 at 11:56
might also depend on if you a pop-up blocker installed. Think some browsers have this facility built-in.
– Loren Rosen
Mar 27 at 16:51
|
show 1 more comment
There seems to be no reliable way to open a new tab in Javascript (a quick search tells it could be tricky), and the code indeeed looks like it is blocking a new page being opened. You can probably try if this works.
Firstly after this line
var href = $(this).attr('href');
add another line that says (this line gets the value of target
attribute/properties from the tag, and assumed to be _self
if undefined)
var target = $(this).prop('target') || '_self';
Then look for this line
$('.site').css('opacity', 0);
What it does is to make the whole page blank essentially. You may want to do something with this, for example wrap it in a if statement so it doesn't execute when target="_blank"
. A quick way to fix it is by replacing it to
target === '_blank' || $('.site').css('opacity', 0);
Next replace (just a few lines after the previous one)
window.location = href;
with
window.open(href, target)
The respective block should look like
load_effect.loader.show();
var href = $(this).attr('href');
var target = $(this).prop('target') || '_self';
target === '_blank' || $('.site').css('opacity', 0);
setTimeout(function()
window.open(href, target)
, load_effect.duration);
This is asuming window.open
works as expected (documentation is here). What happens in the code is that the author stopped the default behavior after clicking a link with
e.preventDefault();
in order to allow some fancy animation to complete before the browser proceeds to load the intended page. However by simplifying the page load with
window.location = href;
it ignores the target attribute/property of the respective <a />
tag.
There seems to be no reliable way to open a new tab in Javascript (a quick search tells it could be tricky), and the code indeeed looks like it is blocking a new page being opened. You can probably try if this works.
Firstly after this line
var href = $(this).attr('href');
add another line that says (this line gets the value of target
attribute/properties from the tag, and assumed to be _self
if undefined)
var target = $(this).prop('target') || '_self';
Then look for this line
$('.site').css('opacity', 0);
What it does is to make the whole page blank essentially. You may want to do something with this, for example wrap it in a if statement so it doesn't execute when target="_blank"
. A quick way to fix it is by replacing it to
target === '_blank' || $('.site').css('opacity', 0);
Next replace (just a few lines after the previous one)
window.location = href;
with
window.open(href, target)
The respective block should look like
load_effect.loader.show();
var href = $(this).attr('href');
var target = $(this).prop('target') || '_self';
target === '_blank' || $('.site').css('opacity', 0);
setTimeout(function()
window.open(href, target)
, load_effect.duration);
This is asuming window.open
works as expected (documentation is here). What happens in the code is that the author stopped the default behavior after clicking a link with
e.preventDefault();
in order to allow some fancy animation to complete before the browser proceeds to load the intended page. However by simplifying the page load with
window.location = href;
it ignores the target attribute/property of the respective <a />
tag.
edited Mar 28 at 3:12
answered Mar 27 at 9:22
Jeffrey04Jeffrey04
3,0049 gold badges36 silver badges60 bronze badges
3,0049 gold badges36 silver badges60 bronze badges
Thanks or the reply @Jeffrey04 ! It worked but a new issue manifests. The link does indeed open in a new tab but the original tab is going blank. The URL remains the same but the content disappeared and reappears on refreshing. If you click on the Instagram link on the main menu at link you'll see what I mean.
– JohnPits
Mar 27 at 10:11
edited, but still doesn't seem to fix your problem, sorry i suppose that's all I can help for now
– Jeffrey04
Mar 27 at 11:07
It worked! Thanks a million, @Jeffrey04 !
– JohnPits
Mar 27 at 11:34
likely won't work in all browsers tho
– Jeffrey04
Mar 27 at 11:56
might also depend on if you a pop-up blocker installed. Think some browsers have this facility built-in.
– Loren Rosen
Mar 27 at 16:51
|
show 1 more comment
Thanks or the reply @Jeffrey04 ! It worked but a new issue manifests. The link does indeed open in a new tab but the original tab is going blank. The URL remains the same but the content disappeared and reappears on refreshing. If you click on the Instagram link on the main menu at link you'll see what I mean.
– JohnPits
Mar 27 at 10:11
edited, but still doesn't seem to fix your problem, sorry i suppose that's all I can help for now
– Jeffrey04
Mar 27 at 11:07
It worked! Thanks a million, @Jeffrey04 !
– JohnPits
Mar 27 at 11:34
likely won't work in all browsers tho
– Jeffrey04
Mar 27 at 11:56
might also depend on if you a pop-up blocker installed. Think some browsers have this facility built-in.
– Loren Rosen
Mar 27 at 16:51
Thanks or the reply @Jeffrey04 ! It worked but a new issue manifests. The link does indeed open in a new tab but the original tab is going blank. The URL remains the same but the content disappeared and reappears on refreshing. If you click on the Instagram link on the main menu at link you'll see what I mean.
– JohnPits
Mar 27 at 10:11
Thanks or the reply @Jeffrey04 ! It worked but a new issue manifests. The link does indeed open in a new tab but the original tab is going blank. The URL remains the same but the content disappeared and reappears on refreshing. If you click on the Instagram link on the main menu at link you'll see what I mean.
– JohnPits
Mar 27 at 10:11
edited, but still doesn't seem to fix your problem, sorry i suppose that's all I can help for now
– Jeffrey04
Mar 27 at 11:07
edited, but still doesn't seem to fix your problem, sorry i suppose that's all I can help for now
– Jeffrey04
Mar 27 at 11:07
It worked! Thanks a million, @Jeffrey04 !
– JohnPits
Mar 27 at 11:34
It worked! Thanks a million, @Jeffrey04 !
– JohnPits
Mar 27 at 11:34
likely won't work in all browsers tho
– Jeffrey04
Mar 27 at 11:56
likely won't work in all browsers tho
– Jeffrey04
Mar 27 at 11:56
might also depend on if you a pop-up blocker installed. Think some browsers have this facility built-in.
– Loren Rosen
Mar 27 at 16:51
might also depend on if you a pop-up blocker installed. Think some browsers have this facility built-in.
– Loren Rosen
Mar 27 at 16:51
|
show 1 more comment
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372821%2fwordpress-theme-blocks-target-blank-on-links-how-do-i-reactivate-it-for-some%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown