/    Sign up×
Community /Pin to ProfileBookmark

change link target for every link on page based on screen size (on load or on resize)

I have a Google Charts table that is loading several links within it. By default, I have links within the cells formatted to open in an iframe called “showme.” What I want to do, when the screen is (or gets) small, is to change the link target to “_blank” since I am hiding the IFRAME using CSS. I have the code below – but it’s not working for even the initial page load. Adding the $(window).on(resize, load…) doesn’t work, either. What syntax is incorrect?

[code]
<script type=”text/javascript”>
function() {
if($(window).width() <= 770)
{$(“a.statutelink”).each(function() {
$(this).attr(“target”, $(this).attr(“target”).replace(“showme”, “_blank”));});
}
};
</script>
[/code]

Thanks.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@jedaisoulAug 29.2016 — Your closing braces do not match the opening ones.
×

Success!

Help @KDLA spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...