Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Dec 2009
    Posts
    51
    Thanks
    7
    Thanked 0 Times in 0 Posts

    How to pass value to newly opened webpage?

    Hi All,

    Can anyone here help me to resolve my problem?

    Problem: I have 10 links on my webpage which opens different media files. When I embed all those media files my webpage takes too much time to load.

    My requirement: To overcome this what I need is I will place 10 different hypertexts (images), which when clicked will open another page (Play_Chord.html) in which the media file will be played. Opening a window on click is easy but where I am stuck is I need to pass the value (media file name) to the new window (which will open) so that it can play that media file.

    I am new to javascript I have searched it net but could not get the working solution.


    My Code (Main.html)

    Code:
    <html>
    <head>
    
    <script language="javascript"> 
    function OpenPlayer(File_Name)
    {
    var w=400;
    var h=200;
    var left = (screen.width/2)-(w/2);
    var top = (screen.height/2)-(h/2);
    
    window.open ("http://mywebsite.com/Play_Chord.html", 'mywindow', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
    }
    </script>
     
    
    </head>
    <body>
    
    <img src="http://mywebsite.com/abcd.jpg" border=0  title="abcd" onClick = " OpenPlayer ('C-Maj.mid')" ></a>
    
    </body>
    </html>
    My Code (Play_Chord.html)

    Code:
    <html>
    <head>
    </head>
    
    <body>
    
    <object id="MediaPlayer1" 
                      classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
                      codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
                      standby="Loading Microsoft® Windows® Media Player components..."
                      type="application/x-oleobject" align="middle">
                     <param name="FileName" value="http://mywebsite.com/File_Name.mid">
                     <param name="autostart" VALUE="false">
                     <param name="ShowControls" VALUE="true">
                     <param name="ShowStatusBar" value="false">
                     <param name="ShowDisplay" VALUE="false">
                     <param name="AutoRewind" VALUE="true">
                         <embed type="application/x-mplayer2" pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/"
                           src="http://mywebsite.com/File_Name.mid"
                           autostart="true" align="middle" width="100" height="45" defaultframe="rightFrame" showstatusbar="false">
                         </embed>
                   </object>
    
    </body>
    </html>
    Please help

    Charles
    Last edited by charles22; 11-17-2010 at 07:35 AM.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,990
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    Several ways.
    a) window.name
    b) query string
    c) cookie.

    This topic has been covered very many times in this forum. Did to try using the search feature?

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
    Last edited by Philip M; 11-17-2010 at 07:58 AM.

  • #3
    New Coder
    Join Date
    Dec 2009
    Posts
    51
    Thanks
    7
    Thanked 0 Times in 0 Posts
    @ Philip M : I have no intention to hurt anyone here. Anyways I have updated my previous thread.

    Could you please suggest how it will go with query string?

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,990
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    Last edited by Philip M; 11-17-2010 at 08:50 AM.

  • Users who have thanked Philip M for this post:

    charles22 (11-17-2010)

  • #5
    New Coder
    Join Date
    Dec 2009
    Posts
    51
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Hi

    I tried a lot and have stuck in this new situation. Now I am able to pass the file name but not able to see media player in the new window. Neither media file is playing. Something wrong with document.getElementById('music1').innerHTML

    Code: Main.html

    Code:
    <html>
    <head>
    
    <script language="javascript"> 
        function OpenViewer(ViewerUrl)
       {
          var w=400;
          var h=200;
          var left = (screen.width/2)-(w/2);
          var top = (screen.height/2)-(h/2);
    
          window.open ("http://www.MyWebsite.com/"+ViewerUrl, 'mywindow', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
        }
    </script>
    
    </head>
    <body>
    
    <input type="submit" value="Play Chord" onClick = "OpenViewer('Play-Chord.html?ChordName=C-Major')"/>
    
    </body>
    </html>
    Code: Play-Chord.html

    Code:
    <html>
    <head>
    
    <script type="text/javascript" language="JavaScript1.2">
     
        function GetParam(name)
        {
           var start=location.search.indexOf("?"+name+"=");
           if (start<0) start=location.search.indexOf("&"+name+"=");
           if (start<0) return '';
           start += name.length+2;
           var end=location.search.indexOf("&",start)-1;
           if (end<0) end=location.search.length;
           var result=location.search.substring(start,end);
           var result='';
           for(var i=start;i<=end;i++) 
           {
              var c=location.search.charAt(i);
              result=result+(c=='+'?' ':c);
           }
           return unescape(result);
        }
        
        aUEntString=GetParam('ChordName');
        aUStrStartPos=aUEntString.indexOf('D');
        aUStrEndPos=parseInt(aUEntString.length);
        aUChordName=aUEntString.substr(aUStrStartPos, aUStrEndPos);
    
        alert("ChordName=" +  aUChordName);
    
        document.getElementById('music1').innerHTML= "<embed type='application/x-mplayer2' pluginspage = 'http://www.microsoft.com/Windows/MediaPlayer/' src='" + aUChordName + "' autostart='true' align='middle' width='100' height='45' defaultframe='rightFrame' showstatusbar='false'></embed>";
    
    </script>
    
    </head>
    <body>
    
    <span id="music1"></span>
    
    </body>
    </html>

    Please help

    Charles


  •  

    Posting Permissions

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