找回密码
 注册
【阿里云】2核2G云服务器新老同享 99元/年,续费同价,云服务器3年机/5年机限时抢购,低至 2.5折华为云精选云产品特惠糖果主机Jtti,新加坡服务器,美国服务器,香港服务器,海外云服务器
查看: 707|回复: 6

一个JS问题

[复制链接]
发表于 2007 年 9 月 1 日 19:41:23 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
有一个JS函数

  1. <script language="JavaScript">
  2. function view(content) {
  3.         document.getElementById('msg').innerHTML=content;
  4. }
  5. </script>
复制代码


目的是在<div id="msg"></div>中显示内容

用<script>view('ddddddd');</script>调用函数显示,却出现缺少对象的错误,是什么问题?
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
发表于 2007 年 9 月 1 日 20:13:11 | 显示全部楼层
【腾讯云】2核2G云服务器新老同享 99元/年,续费同价

  1. <body>
  2. <div id="msg"></div>
  3. ...
  4. ...
  5. <div id="content">...content trans by javascript ...</div>
  6. <script type="text/javascript">
  7. document.getElementById('msg').innerHTML=document.getElementById('content').innerHTML;
  8. document.getElementById('content').innerHTML="";
  9. </script>
  10. </body>
复制代码

不知道这样行不行
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

 楼主| 发表于 2007 年 9 月 1 日 20:17:32 | 显示全部楼层
行:7
字符:1
代码:0
错误:缺少对象
网址:file://C:\Documents and Settings\Administrator\桌面\ddd.htm
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

 楼主| 发表于 2007 年 9 月 1 日 20:20:29 | 显示全部楼层
我把我的完整代码贴出来吧,你看下


  1. <?php
  2.         $SiteName = "feiku.com";        // 采集规则英文标示
  3.        
  4.         if($_POST) {
  5.                 getid($_POST['content']);
  6.         }
  7.         if($_GET['action'] == "view") {
  8.                 viewid();
  9.         }
  10.        
  11.         function getid($content) {
  12.                 global $SiteName;
  13.                 if(preg_match_all('/Book\/([\d]+)\.html/i', $content, $id)) {
  14.                         $count = count($id[1]);
  15.                         $v = "";
  16.                         for($i=0;$i<$count;$i++) {
  17.                                 $v .= $SiteName . "|" . $id[1][$i] . "<br>";
  18.                         }
  19.                         echo "<script>view('$v')</script>";
  20.                 } else {
  21.                         echo "正则表达式匹配错误";
  22.                 }
  23.         }
  24. ?>
  25. <html>
  26. <head>
  27. <title>飞库网ID获取工具</title>
  28. </head>
  29. <body>
  30. <form action="" method="POST">
  31.         <textarea name="content" rows=15 cols=96></textarea><br>
  32.         <input type="submit" value="提交">
  33. </form>
  34. <a href="?action=view">显示ID</a>&nbsp; ;&nbsp; ;&nbsp; ;&nbsp; ;<a href="?action=del">清空ID</a>
  35. <div id="msg">正在采集 <{C_book_title}> 基本信息...</div>
  36. <script language="JavaScript">
  37. function view(content) {
  38.         document.getElementById('msg').innerHTML=content;
  39. }
  40. </script>
  41. </body>
  42. </html>
复制代码


我的目的是在输入框里输入
http://www.feiku.com/Book/ShowBookTop.aspx
的代码,则会把内容显示出来
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2007 年 9 月 2 日 00:16:24 | 显示全部楼层
You can:
<html>
<head>
<title>飞库网ID获取工具</title>

<script language="JavaScript">
function view(content) {
        document.getElementById('msg').innerHTML=content;
}

window.onload = function () {
  view('ddddddd');
);
</script>

</head>
<body>
<form action="" method="POST">
        <textarea name="content" rows=15 cols=96></textarea><br>
        <input type="submit" value="提交">
</form>
<a href="?action=view">显示ID</a>&nbsp; ; ;&nbsp; ; ;&nbsp; ; ;&nbsp; ; ;<a href="?action=del">清空ID</a>
<div id="msg">正在采集 <{C_book_title}> 基本信息...</div>
</body>
</html>
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2007 年 9 月 2 日 00:17:39 | 显示全部楼层
I don't understand your meaning .
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2007 年 9 月 2 日 11:00:30 | 显示全部楼层
【腾讯云】2核2G云服务器新老同享 99元/年,续费同价
Thanks You, My meaning is input html code, msg div view result
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|金光论坛

GMT+8, 2024 年 9 月 20 日 15:32 , Processed in 0.109532 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表