传输Javascript数组 [英] Transfer Javascript Array

查看:68
本文介绍了传输Javascript数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我想将Javascript数组从一页转移到另一页.

1.我不能使用会话,因为我使用会话状态作为StateServer,并且它始终对会话对象执行序列化,并且数组无法序列化.
2.我不能使用Querystring,因为Querystring的大小可能会大于各种浏览器所支持的大小.


该场景如下.

我就像尝试打印一页一样.每当该页面加载到浏览器中时,我都会使用Javascript对加载的图像执行一些操作,在此页面加载期间,我为图像上的标记点创建了一个JavaScript数组.

要打印该页面,我创建了一个.aspx页面,然后使用javascript将其打开到Window.open()方法中.

因此,在将要打印的新窗口中,所有内容都相同,但是我需要标记在父级"页面上创建的标记点.当再次加载javascript文件以打印页面时,我松开了在父"页面上创建的Javascript数组.

如果您听不懂,请告诉我.

已编辑-

该场景如下.

我就像尝试打印一页一样.每当该页面加载到浏览器中时,我都会使用Javascript对加载的图像执行一些操作,在此页面加载期间,我为图像上的标记点创建了一个JavaScript数组.

要打印该页面,我创建了一个.aspx页面,然后使用javascript将其打开到Window.open()方法中.

因此,在将要打印的新窗口中,所有内容都相同,但是我需要标记在父级"页面上创建的标记点.当再次加载javascript文件以打印页面时,我松开了在父"页面上创建的Javascript数组.

如果您仍然无法理解,请告诉我.



谢谢
Anil Indorkar

Hi All,
I want to transfer Javascript array from one page to another.

1. I can not use session as I am using session state as StateServer and it always perform serialization of the session object and array cant be serialized.
2. I can not use Querystring as size of the Querystring can be larger then the supported by various browser.


The scenario is following.

I as trying to Print one page.Whenever this page loads into the browser, I performed some operation on the loaded image using Javascript, during this load of the page I create one JavaScript array for the marking points on the image.

To print that page I have created one .aspx page and I am opening that page using javascript into the Window.open() method.

So all things are same in the new window that is going to be print, but I need marking points that created on the Parent page. As javascript file is loaded again to print the page I have loosed the Javascript array created on the Parent page.

Please let me know if you are unable to understand.

Edited -

The scenario is following.

I as trying to Print one page.Whenever this page loads into the browser, I performed some operation on the loaded image using Javascript, during this load of the page I create one JavaScript array for the marking points on the image.

To print that page I have created one .aspx page and I am opening that page using javascript into the Window.open() method.

So all things are same in the new window that is going to be print, but I need marking points that created on the Parent page. As javascript file is loaded again to print the page I have loosed the Javascript array created on the Parent page.

Please let me know if you still unable to understand.



Thanks
Anil Indorkar

推荐答案

希望这可以帮助您...

网页1(主页或父页面):
-创建一个全局JavaScript变量,例如-imgMarkers,它将存储标记点.
-在window.open()方法中作为参数传递的URL中,再添加一个标志,指示其是从父页面进行的调用(例如-isCalledFromParent)

网页2(子页面):
-使用请求对象或简单的JavaScript URL解析检查isCalledFromParent是否存在.
-如果找到变量,则表示父窗口确实包含所需的标记点数组.
-使用以下代码获取数组的值
Hope this may help you out...

Web-page 1 (Main page or parent page) :
- create one global JavaScript variable, for example - imgMarkers, which will store the marking points.
- in the URL that is passed as argument in window.open() method, add one more flag indicating that its a call from parent page (say for example - isCalledFromParent)

Web-page 2 (Child page) :
- check for the existence of isCalledFromParent using the request object or simple JavaScript URL parsing.
- if variable found, means that the parent window does contain the required marker points array.
- fetch the values of the array using following piece of code
var markerPointsArr = window.opener.imgMarkers;


-根据需要继续操作.

谢谢&问候,
尼拉·索尼(Nial Soni)


- Proceed further as required.

Thanks & Regards,
Niral Soni


这篇关于传输Javascript数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆