/    Sign up×
Community /Pin to ProfileBookmark

Open external website onload?

Hi,
I would like to open/link an external webpage onload in a new tab…

I am using this:
<body onload=window.location=’SITE_URL_HERE’>

This works, but re-directs the page rather than open a new tab.

What would I include so that it does this in a new tab?

Cheers

to post a comment
HTML

1 Comments(s)

Copy linkTweet thisAlerts:
@rtretheweySep 11.2013 — You should use window.open() for this. See [url=http://www.w3schools.com/jsref/met_win_open.asp]http://www.w3schools.com/jsref/met_win_open.asp[/url]. The code would be something like:
<i>
</i>&lt;body onload="window.open('SITE_URL_HERE');"&gt;


However, as you can see, this code creates a new pop-up window and will be blocked by many browser pop-up blockers. You can't force a new tab. It's a user-settable option that determines if a new window is created or the page is loaded in a new browser tab.
×

Success!

Help @dmr123 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 6.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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...