Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-17-2010, 06:16 AM   PM User | #1
charles22
New Coder

 
Join Date: Dec 2009
Posts: 51
Thanks: 7
Thanked 0 Times in 0 Posts
charles22 is an unknown quantity at this point
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..
charles22 is offline   Reply With Quote
Old 11-17-2010, 07:33 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
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..
Philip M is offline   Reply With Quote
Old 11-17-2010, 07:38 AM   PM User | #3
charles22
New Coder

 
Join Date: Dec 2009
Posts: 51
Thanks: 7
Thanked 0 Times in 0 Posts
charles22 is an unknown quantity at this point
@ 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?
charles22 is offline   Reply With Quote
Old 11-17-2010, 08:43 AM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Some useful tutorials:-

http://javascript.about.com/library/blqs.htm

http://www.javascriptkit.com/javatutors/send1.shtml

http://www.htmlgoodies.com/beyond/ja...le.php/3471111

http://www.boutell.com/newfaq/creating/scriptpass.html

http://javascript.internet.com/forms...ng-values.html

But the best and most reliable method (especially in this case) is to use a cookie. There are many examples posted in this forum.

Last edited by Philip M; 11-17-2010 at 08:50 AM..
Philip M is offline   Reply With Quote
Users who have thanked Philip M for this post:
charles22 (11-17-2010)
Old 11-17-2010, 09:33 AM   PM User | #5
charles22
New Coder

 
Join Date: Dec 2009
Posts: 51
Thanks: 7
Thanked 0 Times in 0 Posts
charles22 is an unknown quantity at this point
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
charles22 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:06 AM.


Advertisement
Log in to turn off these ads.