Jump to content

Reference Error


Eldar

Recommended Posts

Hello, I've just started learning PHP, JavaScript and I've got a big problem on my website. I'm getting this ReferenceError. I know what's the problem, but I don't know how to solve it, and I know people can do it for money but I don't have money, I'm searching for someone who's willing to help newbie. As I said I'm begginer, and I know something. The main problem is because I want to use GKPlugin and Player(jwplayer). Plugin need to use object, example:

<object id="flashplayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="600" height="400">
<param name="movie" value="player.swf" />
<param name="allowFullScreen" value="true" />
<param name="allowScriptAccess" value="always" />
<param name="FlashVars" value="plugins=plugins/proxy.swf&proxy.link=http://www.vidbull.com/53qx9uo10k5d" />
<embed name="flashplayer" src="player.swf" FlashVars="plugins=plugins/proxy.swf&proxy.link=http://www.vidbull.com/53qx9uo10k5d" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="600" height="400" />
</object>

Script is generetad just to embed with iframe, and the problem is when I replace it with object, then I'm getting this error. I know that JS can't "call" that iframe to show because I've replaced it with object. You guys probably know about what I'm talking. I'm just searching for some instructions, guidelines from you.
 

    ReferenceError: embeds is not defined
    

    if (embeds[embedid].indexOf("rapidplayer")== iframe_ad){

Here's the rest of code, I think it's used to show iframe.

 

    elseif (substr_count($link,"gorillavid")){
    $video_id = explode("/",$link);
    if (isset($video_id[count($video_id)-1])){
    $video_id = $video_id[count($video_id)-1];
    $embed = '<object id="flashplayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"                                                                      width="600" height="400">
    <param name="movie" value="http://www.kiinc.com/videott/player.swf" />
    <param name="allowFullScreen" value="true" />
    <param name="allowScriptAccess" value="always" />
    <param name="FlashVars" value="plugins=http://www.kiinc.com/videott/plugins/proxy.swf&proxy.link=http://gorillavid.in/'.$video_id.'" />
    <embed name="flashplayer" src="player.swf" FlashVars="plugins=http://www.kiinc.com/videott/plugins/proxy.swf&proxy.link=http://gorillavid.in/'.$video_id.'" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="600" height="400" />
    </object>';


This is the original code. Don't look at providers(source as gorillavid) because I used gorillavid in previous an posted another example from another source (zalaa)
 

    elseif (substr_count($link,"zalaa")){
    $video_id = explode("/",$link);
    if (isset($video_id[count($video_id)-1])){
    $video_id = $video_id[count($video_id)-1];
    $embed = '<IFRAME SRC="http://www.zalaa.com/embed-'.$video_id.'.html" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO WIDTH='.$width.' HEIGHT='.$height.'></IFRAME>';

Function which embed links and should embed GKPlugin/Player:

// general image link

    if (!$embed){
    $embed = "<div style='background-color:#000000; width: ".$width."px; height: ".$height."px;text-align:center;cursor:pointer;' onclick='window.open(\"$link\");'>";
    $embed.= "<p style='text-align:center; padding-top: 70px;'>";
    $embed.= "<a href='$link' target='_blank' style='font-size:24px; color: #ffffff !important'>Click here to play this video</a>";
    $embed.= "</p>";
    $embed.= "</div>";
    }
    return $embed;
    }


JavaScript code:

 

  function getEmbed(embedid){
        if (embeds[embedid].indexOf("rapidplayer")== iframe_ad){
            var html_content =     "<div class='fake_embed' id='fake_embed"+embedid+"' onclick='closeFakeEmbed("+embedid+");'>" +
                                    "<br /><br />" +
                                    "<div class='fake_embed_ad_close'><a href='javascript:void(0);' onclick='closeFakeEmbed("+embedid+");'>Close Ad</a></div>" +
                                    "<div class='fake_embed_ad' id='fake_embed_ad" + embedid +"'>" +
                                        "<iframe src='"+baseurl+"/iframe_ad.php' width='300' height='300' frameborder='NO' border='0'></iframe>" +
                                    "</div>" +
                                    "<div class='fake_embed_bar'><span class='fake_embed_bar_right'></span></div>" +
                                "</div>" +
                                "<div id='real_embed"+embedid+"' style='display:none'>"+embeds[embedid]+"</div>";
            
            
            jQuery('#videoBox'+embedid).html(html_content);
            jQuery('#videoBox'+embedid).show();
        } else {
            jQuery('#videoBox'+embedid).html(embeds[embedid]);
            jQuery('#videoBox'+embedid).show();
        }    
        
    }
    
    function countDown(embedid){
        showCounter = showCounter-1;
        jQuery('span#counter').html(showCounter);
        if (showCounter>0){
            showTimer = setTimeout('countDown('+embedid+');',1000);
        } else {
            showTimer = null;
            showCounter = 20;
            getEmbed(embedid);
        }
    }
    
    function changeEmbed(embedid, counter){
        if (counter == 0){
            jQuery('.embedcontainer').html('');
            jQuery('.embedcontainer').hide();
            getEmbed(embedid);
        } else {
            if (showTimer){
                clearTimeout(showTimer);
            }
            showTimer = null;
            showCounter = counter;
            
            jQuery('.embedcontainer').html('');
            jQuery('.embedcontainer').hide();
            jQuery('#videoBox'+embedid).html(js_lang.ticker);
            jQuery('#videoBox'+embedid+' span#counter').html(showCounter);
            jQuery('#videoBox'+embedid).slideDown("slow");
            
            showTimer = setTimeout('countDown('+embedid+');',1000);
        }
        /*
        jQuery('li.selected').removeClass('selected');
        jQuery('#selector'+embedid).addClass('selected');
        */
    }
Link to comment
https://forums.phpfreaks.com/topic/288926-reference-error/
Share on other sites

It is indeed, as ginerjm says, a JS error. It's caused by this line:

 

if (embeds[embedid].indexOf("rapidplayer")== iframe_ad)
Fairly simple observation; you have a JS function that doesn't define *anything* prior to starting its work.

 

What to do about it? That's more difficult, and, again, this forum is about PHP (although I'd suggest doing something like defining "embeds" in your function ...) :)

Link to comment
https://forums.phpfreaks.com/topic/288926-reference-error/#findComment-1481805
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.