使用javascript缺少的内容更改html内容

时间:2016-01-08 07:20:44

标签: javascript jquery html css

目前我创建了一个页面。该页面将在Safari浏览器中与iPod Touch(第5代)一起显示。此外,页面应以全屏模式显示。

现在我开始解决这个问题,但缺少一些内容。 这是我的首页index.html



<!DOCTYPE html>
<html>

<head>
  <link rel="stylesheet" type="text/css" href="css/desktop.css">
  <link rel="stylesheet" type="text/css" href="css/ipod.css">

  <script src="js/jquery-1.11.3.min.js"></script>

  <meta name="apple-touch-fullscreen" content="yes" />
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black">

  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>

<body>
  <div id="content">
    <div id="dumpingStationButtonContainer">
      <a id="dumpingStationOneButton" class="dumpingStationButton">Lader&uuml;ssel 1</a>
      <a id="dumpingStationTwoButton" class="dumpingStationButton">Lader&uuml;ssel 2</a>
    </div>
  </div>

  <script type="text/javascript">
    $(document).ready(function() {
      $('#dumpingStationOneButton').click(function() {
        $('body').load("dumpingStationOne.html");
      });

      $('#dumpingStationTwoButton').click(function() {
        $('body').load("dumpingStationTwo.html");
      });
    });
  </script>
</body>

</html>
&#13;
&#13;
&#13;

dumpingStationOne.html

&#13;
&#13;
<div id="content">
  <div id="cameraContainer">
    <script type="text/javascript">
      var sDomainPort = 80;
      var Speck_var = 0;
      var channel_s = 0;
      var view_w = 900;
      var view_h = 675;


      if (window.innerWidth > 0) {
        window_width = window.innerWidth;
      } else {
        window_width = screen.width;
      }

       if (window_width < 981) {
        var percent = window_width / view_w;
        view_w = window_width;
        view_h = percent * view_h;
      }

      function onLive(sDomainURL, test) {
        var ret;
        var obj = document.getElementById(test);
        obj.Author('admin', 'admin');
        obj.SetDateFormat(0);
        obj.SingleAudio = 0;
        obj.VideoPath = channel_s;
        obj.UnderScan = 1;
        obj.ROILEFT = 0;
        obj.ROITOP = 0;
        obj.ROIRIGHT = 0;
        obj.ROIBOTTOM = 0;

        //var bSuccess = obj.CheckInitState;
        //if (bSuccess == 0) {
        //	setTimeout("onLive();", 1000);
        //	return;
        //}
        obj.LivePlay(sDomainURL, sDomainPort, sDomainPort, 0);
      }

      function closeActiveX(test) {
        var obj = document.getElementById(test);
        obj.CloseActiveX();
      }

      document.write('<object id="LiveShow1" classid="clsid:f9bf64a0-5a65-43e0-acdb-b223e7f9ddd9" CODEBASE="WEBWATCH2.cab#version=1,2,5,24" width="' + view_w + '" height="' + view_h + '"> ');
      document.write('<img id="camera" width="' + view_w + '" height="' + view_h + '" src="http://192.168.1.195/GetData.cgi?CH=1" alt="Die Verbindung wurde unterbrochen. Bitte warten..."</img>');
      document.write('</object>');
    </script>
  </div>

  <div id="operationButtonContainer">
    <a id="btnMoveUp" unselectable="on" class="operationButton">Heben</a>
    <a id="btnStartStop" unselectable="on" class="operationButton">Start</a>
    <a id="btnMoveDown" unselectable="on" class="operationButton">Senken</br></a>
    <div id="circleDiv">
      <div id="lifeCircle" class="greenCircle"></div>
    </div>
    <a id="btnBack" unselectable="on" class="operationButton" href="index.html">Zur&uuml;ck</a>
  </div>
  <div class="clearBoth"></div>
</div>
&#13;
&#13;
&#13;

缺少按钮。而且代码错了,我在页面右键点击了 - &gt;显示代码,页面上的代码为:

<object id="LiveShow1" classid="clsid:f9bf64a0-5a65-43e0-acdb-b223e7f9ddd9" CODEBASE="WEBWATCH2.cab#version=1,2,5,24" width="900" height="675"> <img id="camera" width="900" height="675" src="http://192.168.1.195/GetData.cgi?CH=1" alt="Die Verbindung wurde unterbrochen. Bitte warten..."</img></object>

多数民众赞成。按钮丢失了。我错了什么?任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

&#34;文件撰写&#34;替换页面上的所有内容。使用document.getElementById(&#39; myDiv&#39;)。innerHTML =&#34; text&#34 ;;代替。像这样:

import java.awt.GridLayout;
import java.awt.Window;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
 class MyDialogParent extends JDialog {

     MyDialogParent ()
    {
        super(null,ModalityType.MODELESS);

    //    super.setUndecorated(true);
        super.setVisible(false);


        // Disable Alt-F4 and any other close key sequences (MMSmk90468).
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }

     @Override
        public void setVisible(boolean b)
        {
         System.out.println("parent visiblity its overridden method b : "+b);
            super.setVisible(b);
        }

}

 class MyDialogChild extends JDialog {

     MyDialogChild (Window parent)
        {
         super(parent,ModalityType.MODELESS);
         setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            setAlwaysOnTop(true);


        }

     @Override
        public void setVisible(boolean b)
        {
         System.out.println("child visibility in its overridden method  b : "+b);

            super.setVisible(b);

        }
    }


public class MyDialogs {

    public static void main(String args[])
    {
        MyDialogParent parent=new MyDialogParent();
        parent.setSize(400, 400);
        System.out.println("parent.isVISIBLE : "+parent.isVisible());

        parent.setVisible(true);
        System.out.println("parent.isVISIBLE a : "+parent.isVisible());
        System.out.println("1");
        System.out.println("2");
        System.out.println("3");

        MyDialogChild child=new MyDialogChild(parent);
        child.setLocationRelativeTo(parent);
        child.setSize(300, 300);
        child.setLayout(new GridLayout());
        child.add(new JPanel());
        System.out.println("child.isVISIBLE : "+child.isVisible());
        child.setVisible(true);
        System.out.println("child.isVISIBLE a : "+child.isVisible());

        System.out.println("5");
        System.out.println("6");
        System.out.println("parent.isVISIBLE : "+parent.isVisible());
        System.out.println("child.isVISIBLE : "+child.isVisible());
        parent.setVisible(false);
        System.out.println("parent.isVISIBLE a : "+parent.isVisible());
        System.out.println("child.isVISIBLE a : "+child.isVisible());
    //  child.setVisible(true);
    }
    }