javascript - 通过Javascript在另一个html页面中显示HTML表单

标签 javascript jquery html forms display

我有两个单独的 html 文件。第一个是主页。

Main Page

第二个是属性面板,每当将工具从左侧工具箱拖放到 Canvas 上时,该面板就需要出现在上一页 Canvas 的右侧。

enter image description here

我之前就这样做了,将属性面板表单作为邮件页面(第一张图片)所在的同一 html 页面的一部分。

但是由于还会有各种其他表单/属性面板,我想将其提取到不同的 html 表单并调用它们从我的 jsGold.js 文件中显示在这个位置(右侧)。

文件结构如下:

File structure

StreamProperty.html 以以下形式保存属性面板表单

<head>
<link rel="stylesheet" type="text/css" href="../../CSS/style.css">
<link rel="stylesheet" type="text/css" href="../../CSS/propertybox.css">
</head>
<body>

<div style="float: left">
    <h1 class="toolbox-titlex" id="tth">Properties Panel</h1>
    <form class="panel"  id="lot">
        <label>Stream Type:</label>
        <div class="panel-switch">
            <input type="radio" name="TypeGen" value="G" id="type_g" class="panel-switch-input" checked>
            <label for="type_g" class="panel-switch-label">Import</label>
            <input type="radio" name="TypeGen" value="A" id="type_a" class="panel-switch-input">
            <label for="type_a" class="panel-switch-label">Export</label>
            <input type="radio" name="TypeGen" value="B" id="type_b" class="panel-switch-input">
            <label for="type_b" class="panel-switch-label">Temporary</label>
        </div>
        <input type="text" class="panel-input-streamName" placeholder="Stream Name">
        <input type="text" class="panel-input-streamDef" placeholder="Stream Definition">
        <input type="button" value="Save" class="panel-button">
        <input type="reset" value="Reset" class="panel-button-reset">
        <input type="button" value="Cancel" class="panel-button-cancel">
    </form>
</div>
</body>

我需要通过 JavaScript 在以下位置显示此表单。由于不涉及按钮单击,而只是 jsPlumb 下降,因此我不确定如何完成此操作。

jsGold.js

$("#container").droppable({
      accept: '.project, .query',
      containment: 'container',
      /**
       *
       * @param e --> original event object fired/ normalized by jQuery
       * @param ui --> object that contains additional info added by jQuery depending on which interaction was used
       * @helper clone
       */
      drop: function(e, ui) {
          var dropElem = ui.draggable.attr('class');
          alert('drop element: ' + dropElem);
          droppedElement = ui.helper.clone();
          //jsPlumb doesn't support jQuery cloneUI method.
          //So once the icon is dragged and dropped on the canvas, the clone UI class will be removed
          ui.helper.remove();
          $(droppedElement).removeAttr("class");
          // repaint --> Recompute and position all the connections
          jsPlumb.repaint(ui.helper);
          //Add the 'pro' class which has the same styling as the 'project' class but differs in functionality
          //This avoids the duplication of another project class when one project class is being dragged and dropped
          if (dropElem == "project ui-draggable") {
            var newAgent = $('<div>').attr('id', i).addClass('pro');
            //Reset Property fields
            $("#lot")[0].reset();
            //Display the Properties panel when the element is Clicked
            $(".toolbox-titlex").show();
            $(".panel").show();
          } else {
            var newAgent = $('<div>').attr('id', i).addClass('que');
            alert("que added");
          }

          //Reset Property fields
          $("#lot")[0].reset();

我需要一个替代方法来执行此操作,而不是上面文件中的以下行

//Display the Properties panel when the element is Clicked
$(".toolbox-titlex").show();
$(".panel").show();

最佳答案

您可以使用frame标签在另一个html中显示一个html表单

<!DOCTYPE html>
<html>

<frameset cols="100%">
  <frame src="form_a.htm">
</frameset>

</html>
http://quandaflow.com/

关于javascript - 通过Javascript在另一个html页面中显示HTML表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37743190/

相关文章:

javascript - 以 Angular 添加样式

javascript - chrome 扩展 - 将外部照片加载到 img 中 - 避免混合内容

javascript - 如何使用 javascript/jquery 更改每行文本的文本方向?

javascript - React : Cannot update during an existing state transition (such as within `render` ). 渲染方法应该是 props 和 state 的纯函数

javascript - 什么时候应该使用 getInnerHtml() 方法?

javascript - 如何将日期选择器插入 MS Excel 单元格

jquery - 将下拉列表的值传递到文本框

Javascript/jQuery 图像裁剪器无法工作

javascript - 获取在 HTML 输入中选择的文件的绝对文件名而不是路径

javascript - 使用 jQuery 更改背景图片