/    Sign up×
Community /Pin to ProfileBookmark

Help…Almost Got It

I’m trying to create a link on our website that goes to a training video on youtube and want it to open in a window with a specific size and location on the page. We also want to inform the viewer that they will be leaving our site to view the video.

Everything is working as planned except if “Cancel” is clicked on the pop up message stating they are going to leave our site the movie still opens. I took the window.open out of the popup message code otherwise the video opened in two windows. One with the correct size and location.

Here is the code going to the link with the onclick function.

<a href=” http://www.youtube.com/watch?v=t5KibZuz6Kk” onclick=”leaveCheck2(this.href); basicPopup(this.href); return false; “>

Popup Message Code

<script>
function leaveCheck2(url) {
if(confirm(“We hope you enjoy our video. However you are being redirected to [url]www.youtube.com[/url] and Apple River State Bank is not responsible for services beyond this point.”))(url)
}
</script>

Window Size & Location Code

<script>
// JavaScript popup window function
function basicPopup(url) {
popupWindow = window.open(url,’popUpWindow’,’height=375,width=640,left=300,top=300,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no, status=yes’)
}
</script>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@rtretheweyAug 20.2013 — Why not avoid the issue (and save the user an unnecessary click) by embedding the YouTube video in a page on the parent website and display that in the pop-up window? Simply hosting the video on the parent site might even be better unless you have bandwidth issues.
Copy linkTweet thisAlerts:
@AirbladerAug 22.2013 — Methods like alert and confirm are widely considered "out of date" and should be avoided in favor of proper DOM methods to display these information (a simple, small lable shoulf suffice). Popups are frowned upon, too. Embedding the video should be just about the best way to do this these days. There shouldn't be any bandwidth issues as the video content will not be downloaded until the video is started (actually, then they won't be leaving your site anymore).
×

Success!

Help @webdone 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.16,
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,
)...