JBTALKS.CC

标题: 關于一些制作網頁的問題 [打印本页]

作者: 虚空使者    时间: 2009-2-15 11:28 AM
标题: 關于一些制作網頁的問題
雖然說是assignmet
但咱還是想用心去做
所以有可能用到了了lecturer還沒教到、或者根本沒教的東西
所以跑去用了javascript
但是咱不懂要怎樣add個start/pause, stop control進去
google找了很多多數都是HTML的
有誰可以教咱嗎?
  1. <script>
  2. <!--
  3. var musicsrc="my music.mp3"
  4. if (navigator.appName=="Microsoft Internet Explorer")
  5. document.write('<bgsound src='+'"'+musicsrc+'"'+' loop="infinite">')
  6. else
  7. document.write('<embed src=\"'+musicsrc+'\" hidden="true" border="0" width="20" height="20" autostart="true" loop="true">')
  8. //-->
  9. </script>
复制代码

當然這不是咱寫出來的東西。。。
作者: Super-Tomato    时间: 2009-2-15 12:23 PM
原帖由 虚空使者 于 2009-2-15 11:28 AM 发表
雖然說是assignmet
但咱還是想用心去做
所以有可能用到了了lecturer還沒教到、或者根本沒教的東西
所以跑去用了javascript
但是咱不懂要怎樣add個start/pause, stop control進去
google找了很多多數都是H ...



html 的 background sound 無法控制開始暫停或停止, 除非你使用 Flash


p/s: 或者嵌入 WMP 或 Quicktime 等會比較簡單, 但非 Windows 或無安裝這類軟體的使用者就無法使用

[ 本帖最后由 Super-Tomato 于 2009-2-15 12:26 PM 编辑 ]
作者: 虚空使者    时间: 2009-2-15 12:50 PM
标题: 回复 #2 Super-Tomato 的帖子
是說用類似下面這東西嗎?

  1. <OBJECT ID="mediaPlayer"
  2. CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
  3. CODEBASE="http://activex.microsoft.com/activex/
  4. controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
  5. STANDBY="Loading Microsoft Windows Media Player components..."
  6. TYPE="application/x-oleobject">
  7. <PARAM NAME="filename"
  8. VALUE="narcacepticle - born to loose.mp3">
  9. <PARAM NAME="transparentatStart" VALUE="true">
  10. <PARAM NAME="autoStart" VALUE="false">
  11. <PARAM NAME="showcontrols" VALUE="true">
  12. <PARAM NAME="volume" VALUE="-200">
  13. <param name="PlayCount" value="10">
  14. </OBJECT>
复制代码

但是沒有其他比較好的方法了嗎?
咱以前的blog有放過這個東西

  1. <embed allowscriptaccess="never"  type="application/x-shockwave-flash" wmode="transparent" width="120" height="20" align="middle"></embed><a style="font-size:9px;color:#ccc;letter-spacing:-1px;text-decoration:none;" target="_blank" href="http://boomp3.com/listen/c1pptxg4o_z/key-to-my-heart-倉木麻衣">Boomp3.com</a>
复制代码

那時有能control start stop
只是最近不懂怎么沒了
但是這code放進去咱網頁。。。不能work。。。
作者: Super-Tomato    时间: 2009-2-15 01:08 PM
原帖由 虚空使者 于 2009-2-15 12:50 PM 发表
是說用類似下面這東西嗎?


  1. <OBJECT ID="mediaPlayer"
  2. CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
  3. CODEBASE="http://activex.microsoft.com/activex/
  4. controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
  5. STANDBY="Loading Microsoft Windows Media Player components..."
  6. TYPE="application/x-oleobject">
  7. <PARAM NAME="filename"
  8. VALUE="narcacepticle - born to loose.mp3">
  9. <PARAM NAME="transparentatStart" VALUE="true">
  10. <PARAM NAME="autoStart" VALUE="false">
  11. <PARAM NAME="showcontrols" VALUE="true">
  12. <PARAM NAME="volume" VALUE="-200">
  13. <param name="PlayCount" value="10">
  14. </OBJECT>
复制代码


但是沒有其他比較好的方法了嗎?
咱以前的blog有放過這個東西


  1. <embedallowscriptaccess="never"  type="application/x-shockwave-flash"wmode="transparent" width="120" height="20"align="middle"></embed><astyle="font-size:9px;color:#ccc;letter-spacing:-1px;text-decoration:none;"target="_blank"href="http://boomp3.com/listen/c1pptxg4o_z/key-to-my-heart-倉木麻衣">Boomp3.com</a>
复制代码


那時有能control start stop
只是最近不懂怎么沒了
但是這code放進去咱網頁。。。不能work。。。



第一種就是使用 WMP 的 ActiveX 插件播放, 缺點方面我已經提過了
第二種就是使用 Flash 播放器,  至於不能 work 的原因有可能是該 mp3 歌曲失連, 又或該網站已經不提供 crossdomain 連結, 建議把 mp3 歌曲放在 flash 同主機或路徑下, 然後修改 Flash 讀取指定路徑下的 mp3.
作者: 虚空使者    时间: 2009-2-15 01:51 PM
标题: 回复 #4 Super-Tomato 的帖子
咱是照你建議來用其他的flashplayer
但是咱不知道要怎樣放align right跟infinite loop。。==
可以指點一下嗎?
咱對于javascript方面還是個新手
  1. <script type="text/javascript" src="material/flash/swfobject.js"></script>
  2.                
  3. <div id="flashPlayer">
  4.   This text will be replaced by the flash music player.
  5. </div>

  6. <script type="text/javascript">
  7.    var so = new SWFObject("material/flash/playerMini.swf", "mymovie", "75", "30", "7", "#FFFFFF");
  8.    so.addVariable("autoPlay", "yes");
  9.    so.addVariable("soundPath", "material/artonelico.mp3");
  10.    so.write("flashPlayer");
  11. </script>
复制代码

作者: Super-Tomato    时间: 2009-2-15 03:07 PM
原帖由 虚空使者 于 2009-2-15 01:51 PM 发表
咱是照你建議來用其他的flashplayer
但是咱不知道要怎樣放align right跟infinite loop。。==
可以指點一下嗎?
咱對于javascript方面還是個新手
               

  1. <script type="text/javascript" src="material/flash/swfobject.js"></script>
  2.                
  3. <div id="flashPlayer">
  4.   This text will be replaced by the flash music player.
  5. </div>

  6. <script type="text/javascript">
  7.    var so = new SWFObject("material/flash/playerMini.swf", "mymovie", "75", "30", "7", "#FFFFFF");
  8.    so.addVariable("autoPlay", "yes");
  9.    so.addVariable("soundPath", "material/artonelico.mp3");
  10.    so.write("flashPlayer");
  11. </script>
复制代码




这就要看你们的Flash怎么编写的,而不是 JS 的问题

   so.addVariable("autoPlay", "yes");
   so.addVariable("soundPath", "material/artonelico.mp3");

这两句只是从 JS 初始 Flash 中的两个全域变数
作者: 虚空使者    时间: 2009-2-15 03:55 PM
标题: 回复 #6 Super-Tomato 的帖子
咱這個JS還有外連一個material/flash/swfobject.js
但是里面有更多一堆看不懂的東西
也不關它的事嗎?
問題完全在于flash?
作者: Super-Tomato    时间: 2009-2-16 02:22 AM
原帖由 虚空使者 于 2009-2-15 03:55 PM 发表
咱這個JS還有外連一個material/flash/swfobject.js
但是里面有更多一堆看不懂的東西
也不關它的事嗎?
問題完全在于flash?



播放 mp3 的是 flash player, 當然掌控重要編程的自然就落在 flash 中,就算你不要 swfobject.js 也不會怎樣,只要使用 <embed> 標籤插入 flash 即可
作者: 虚空使者    时间: 2009-2-26 09:23 AM
  1. <html>
  2. <head>
  3. <title> Form validation </title>
  4. <script language="Javascript">
  5. function validate_email(field)
  6. {
  7.     with (field)
  8.     {
  9.         apos=value.indexOf("@"); //find the position of the @ character
  10.         dotpos=value.lastIndexOf(".");//find the last position of the . character
  11.         if (apos<1|| dotpos-apos<2)
  12.         {
  13.             alert("Not a valid e-mail address!"); return false;
  14.         }    else return true;
  15.     }
  16. }
  17. function validate_length(field)
  18. {
  19.     with(field)
  20.     {
  21.         if (value.length == 0)
  22.         {   
  23.             alert("Cannot be empty!"); return false;
  24.         }else return true;
  25.     }
  26. }
  27. function validate_form(thisform)
  28. {
  29.     with (thisform)
  30.     {
  31.         if (validate_length(yourname) == false)
  32.         {
  33.             yourname.focus(); return false;
  34.         }
  35.         if (validate_length(email)==false || validate_email(email)==false)
  36.             {
  37.             email.focus(); return false;
  38.             }
  39.     }
  40. }
  41. </script>
  42. </head>
  43. <body>
  44.     <form action="submitpage.htm" onsubmit="return validate_form(this);" method="post">
  45.     <br>Name : <input type="text" name="yourname" value="">
  46.     <br>Email : <input type="text" name="email" size="30">
  47.     <input type="submit" value="Submit">
  48. </form>
  49. </body>
  50. </html>
复制代码

加入了validate的功能
但是submit去的那個page要怎樣收入submit的東西?
作者: Super-Tomato    时间: 2009-2-26 09:58 AM
原帖由 虚空使者 于 2009-2-26 09:23 AM 发表


Form validation

function validate_email(field)
{
    with (field)
    {
        apos=value.indexOf("@"); //find the position of the @ character
        dotpos=value.lastIndexOf(".") ...



html 无法接收 POST method 的 parameters

1. 改成 GET method 然后在该 submitpage 取得网址後判段 parameters
2. 使用 ASP, PHP, JSP 等


最后如果要赋予 Flash 中这两个值的话,就去參考 FlashVars 的 param 设定
作者: 虚空使者    时间: 2009-2-28 05:26 PM
标题: 回复 #10 Super-Tomato 的帖子
咱lecturer是叫咱用這個來做成guest book。。。
咱是只會改成get。。。但是取得網址後判斷parameters是什么意思?
順便在這里問多一些東西好了
  1. <html>
  2. <head>
  3. <title>Strings</title>
  4. <script>
  5.         var str = new String("hippo");
  6.         //the length method returns the number of characters in the string object
  7.         var len = str.length;
  8.         document.writeln("<BR>" + "There are " + len + " characters in " + str);

  9.         //the charAt method returns the character at the index specified by its parameter.
  10.         var ch = str.charAt(2);
  11.         document.writeln("<BR>" + " The character at index 2(location 3) in " + str + " is " +ch);

  12.         //to display the string in upper case(or lowercase) use the toUpperCase method (or toLowerCase)
  13.         document.writeln("<BR>" + "The string in upper case is " + str.toUpperCase());

  14.         //to get the index of the first occurence of the character in the String object use the IndexOf method
  15.         var idx = str.indexOf('p');
  16.         document.writeln("<BR>" + "The FIRST occurence of the character p is at index " + idx);

  17.         //to get the index of the last occurence of the character in the String object use the IndexOf method
  18.         var lastidx = str.lastIndexOf('p');
  19.         document.writeln("<BR>" + "The LAST occurence of the character p is at index " + lastidx);

  20. </script>
  21. </head>
  22. <body>
  23. </body>
  24. </html>
复制代码
  1. <html>
  2. <head>
  3. <title>Arrays</title>
  4. <script>
  5.         var names = new Array(4);      //declaring an array of 4 objects;
  6.         
  7.         //initializing the elements with 4 String objects
  8.         names[0] = "Jack";   names[1] = "Alfred";   names[2] = "Steve";   names[3] = "Robert";

  9.         var len = names.length;  //the length property returns the number of items in the array object
  10.         document.writeln("<BR>" + "There are " + len + " names in the array ");

  11.         //to display a particular element in the array use the index value -this is how we access the first element -Index 0
  12.         document.writeln("<BR>" + "The first name in the array is " + names[0]);

  13.         document.writeln("<BR>" + "The list contains ");
  14.         for (x in names)            // to display all elements in the array sequentially you need to use a loop
  15.                 document.write(" " +names[x]);
  16.         
  17.         document.writeln("<BR>" + "The list is reverse order => " + names.reverse());   //to display the contents in reverse order
  18.         
  19.         document.writeln("<BR>" + "The list is sorted order +> " +names.sort());     //to display the contents in sorted order

  20.         document.writeln("<BR>" + "Removing " + names.pop() + " from the array");
  21.         document.writeln("<BR>" + "Now the array contains " + names.length + " elements");   //removing the last element of the array

  22.         names.push("James");  //adding an item to the array
  23.         document.writeln("<BR>" + "After adding James, the array now contains " + names.length + " elements");

  24. </script>
  25. </head>
  26. <body>
  27. </body>
  28. </html>
复制代码
打了這么多
卻就出那幾行字而已。。。
有特別的用意在嗎?
作者: Super-Tomato    时间: 2009-2-28 06:44 PM
原帖由 虚空使者 于 2009-2-28 05:26 PM 发表
咱lecturer是叫咱用這個來做成guest book。。。
咱是只會改成get。。。但是取得網址後判斷parameters是什么意思?
順便在這里問多一些東西好了


使用 get 提交的话,所导向的页面网址会类似这样  submitpage.htm?yourname=xxxx&email=xxxx@xxxx
所以你就要用以下 String 的方法取得使用者所提交的 yourname 和 email 的参数



  1. <html>
  2. <head>
  3. <title>Strings</title>
  4. <script>
  5.         var str = new String("hippo"); //定义新字串
  6.         var len = str.length;  //取得新字串的长度
  7.         document.writeln("<BR>" + "There are " + len + " characters in " + str);

  8.         var ch = str.charAt(2); //取得字串中排列在第2位的文字(一切阵列形式起始位置由0开始)
  9.         document.writeln("<BR>" + " The character at index 2(location 3) in " + str + " is " +ch);

  10.         //把字串转换为大写
  11.         document.writeln("<BR>" + "The string in upper case is " + str.toUpperCase());

  12.         //找出 p 文字所在的位置
  13.         var idx = str.indexOf('p');
  14.         document.writeln("<BR>" + "The FIRST occurence of the character p is at index " + idx);

  15.         //找出 p 文字所在的最后位置
  16.         var lastidx = str.lastIndexOf('p');
  17.         document.writeln("<BR>" + "The LAST occurence of the character p is at index " + lastidx);

  18. </script>
  19. </head>
  20. <body>
  21. </body>
  22. </html>
复制代码

这个例子只是為了讓你们了解 String 这个 class 有哪些常用的 methods 和 attributes 可以使用




  1. <html>
  2. <head>
  3. <title>Arrays</title>
  4. <script>
  5.         var names = new Array(4);      //定义单阵列长度为 4
  6.         
  7.         //赋予4个阵列不同的 String 值
  8.         names[0] = "Jack";   names[1] = "Alfred";   names[2] = "Steve";   names[3] = "Robert";

  9.         var len = names.length;  //取得阵列的长度
  10.         document.writeln("<BR>" + "There are " + len + " names in the array ");

  11.         //取得阵列 0 位置的值
  12.         document.writeln("<BR>" + "The first name in the array is " + names[0]);

  13.         document.writeln("<BR>" + "The list contains ");
  14.         for (x in names)            //使用 for ... in 把阵列内的值列出
  15.                 document.write(" " +names[x]);
  16.         
  17.         document.writeln("<BR>" + "The list is reverse order => " + names.reverse());   //倒转阵列的排列,為了验证是否已经倒转排列的话可以使用 for...in 列印出来检查
  18.         
  19.         document.writeln("<BR>" + "The list is sorted order +> " +names.sort());     //把阵列缩排, 同上方法可以验证

  20.         document.writeln("<BR>" + "Removing " + names.pop() + " from the array");  //使用 pop 把阵列最后一个位置给移除,所以names阵列就只剩下3个长度
  21.         document.writeln("<BR>" + "Now the array contains " + names.length + " elements");   //取得阵列长度

  22.         names.push("James");  //使用 push 把新的 string 加入到阵列最后的排列
  23.         document.writeln("<BR>" + "After adding James, the array now contains " + names.length + " elements");  //同樣可以取得长度验证已经加入或使用 for...in 验证看看

  24. </script>
  25. </head>
  26. <body>
  27. </body>
  28. </html>
复制代码


这也是和 String 的例子一樣要让你了解 Array 阵列怎么使用和有哪些方法和属性,當然 Array 的方法還有很多,可以到 SUN 网站去查看








以上的例子要做 guestbook 是不太可能,除非你的 lecturer 是要你们使用 AJAX 从后台(asp, php, jsp 等)取得留言资料,不然单单 Javascript 只能在使用者端执行而无法在 server 上储存任何资料。
作者: 虚空使者    时间: 2009-2-28 07:25 PM
标题: 回复 #12 Super-Tomato 的帖子
其實他要我們做的guest book并不是要輸入進server的
我們做的網站也不過是整個folder給他去mark
就單單只是練習一些基本的網站制作。。。并不是真正去放在網上的。。。
那么如果只是這樣的話上面的這些就夠了嗎?

話說那些script有點難消化。。。
很深奧。。。
要花時間來研究了。。。




欢迎光临 JBTALKS.CC (https://www.jbtalks.cc/) Powered by Discuz! X2.5