SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    381
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Run javascript on page load and not click link

    I'm setting up a video gallery on a site. What I want to happen is that when the user clicks on a thumbnail it then opens and plays the corresponding video clip in shadowbox.

    What shadowbox opens is a page which holds the video player object. What I need to happen is for the video reference to be passed to the page that shadowbox opens.

    I don't know how to do this. I can get this working where the thumbnails are all on the same page as the video player object. The link on the thumbnail images is as follows:

    <a href="javascript:loadVideo('rb6RuHSMY-8');"><img src="data/thumbnails/01.jpg" width="118" height="66" alt="video" /></a>

    What I was trying to set up was to get the page that shadowbox opens to automatically run the loadVideo javascript with the reference variable passed to it in the url.

    Can anyone help me out as to how I would set up the javascript to work please?

    any help as always much appreciated.

    Thanks in advance.

  2. #2
    SitePoint Evangelist TommiChi's Avatar
    Join Date
    Oct 2008
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you have to open it in a new page, why don't you open a template page (playvideo.html?vidId=rb6RuHSMY-8), that will also contain a reference to your shadowbox JS file, as well as a playvideo.js file. In this file you place some code like:
    window.onload = function()
    {
    var videoId = window.location.search.replace('?vidId=', '');
    loadVideo(videoId)
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •