This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术讨论 / 如何在网页里放置一个值,这个值只针对一个窗口,如果打开另外一个窗口,那个值需要有相应的变化呢?其实就象赋予浏览器一个 identifier 那样
问题是有很多不同的情况要处理:
1,比如打开window A,B 分别打开那个网页,那个ID在 A,B 里应该完全不一样的值
2,在 A 用鼠标右键打开 B
3,在 A 用鼠标左键打开 B
4,IE 里面可以 clone 一个 B
5,FF, IE7, OPERA 里面每个 TAB 都需要有不同的值
有什么好的想法没有?
已经在考虑了很多天,不好解决
-sowen(昂居居);
2008-4-21
{331}
(#4406927@0)
-
1what's the original requirement? do you have to id different browser windows? 2. do you want the id to stay the same when a user refresh/visit another page in your app in the SAME browser window? If not,does it mean you just want an id for every single http request?
-fatbean(_);
2008-4-21
{63}
(#4406956@0)
-
we want the ID for every browser. the original requirement is way too complicated to describe. we r having some techniques to deal with IE, but the same technique cannot work for FF. and I don't like that technique anyway. it's ASP.NET btw
-sowen(昂居居);
2008-4-21
(#4406986@0)
-
很奇怪的需求。考虑过iframe没有?
-holdon(again);
2008-4-22
{209}
(#4407830@0)
-
好主意!iframe 是不行的,不过我发现用一个 invisible frame 其实是可以保证声称一个 unique identifier for a browser
-sowen(昂居居);
2008-4-22
(#4408246@0)
-
其实不如干脆diable right click, 所有的页面内link都用 href='javascript:openpage()' 来做,右键根本打不开。我的理解是从server side, 左键和右键打开的页面是没有任何区别的, 所以一定是client side javascript来判断是否是新窗口。这样页面的内容也一定要由javascript 来控制显示,所以Ajax是必然的。
tab index 之类跨浏览器有问题, 页面自身也没有任何id, 所以从parent页面入手是可行的。我不明白你如何用隐藏frame, 在隐藏frame之外的任何连接,你还是么办法区分左键和右键打开啊。
-holdon(again);
2008-4-22
{355}
(#4408338@0)
-
那个我早就问过了,很不幸是一个 business need 必须支持。我说的方法是用一个 container,如果invisible frame url 没有 querystring,就在 code-behind 生成一个 guid,因为那个 frame url 是不会改变的,所以永远都在那里那个 invisible frame url 里的 guid 就是每个窗口的 unique identifier
我已经实验过,
- 用 separate browser 访问是肯定的
- 当 ctrl+n 打开一个窗口,可以生成一个新 guid
- 如果用右键打开,需要用 js 检查有没有 frame,如果没有就 redirect 到 container url
目前实验中 so far so good,正在考虑还有什么别的情况
-sowen(昂居居);
2008-4-22
{308}
(#4408352@0)
-
there is a way, you can store the id inside database, but might not a good solution for a public webpage.
-sunday8(sunday8);
2008-4-22
(#4408292@0)
-
How about saving the value in a HTML hidden control? The value of hidden control can be changed either on server side or client side.
-deep_blue(BLUE);
2008-4-22
(#4408421@0)
-
that wont work pal, how can you tell if a new window is opened? if you ctr+N to open a new one, the hidden field already has the value in it.
-sowen(昂居居);
2008-4-22
(#4408433@0)
-
It depends. If you use .NET, you can tell on server side.
-deep_blue(BLUE);
2008-4-22
(#4408556@0)
-
hmm, interesting, how can you tell? because when cloning a single page, it doesn't make a request (even though it's said it actually makes), the hidden field just copies the identical value from the original browser.on the other hand, if you store it in a hidden field, how do you pass the value from it to another page in GET?
-sowen(昂居居);
2008-4-22
{111}
(#4408597@0)
-
Actually, when you use Ctrl + N to start the page itselfit sends request to server without any data from existing except Session ID. It means it’s a new request but from existing Session. If the business logic doesn’t allow this kind operation. you should have someway to alert user stop further action.
-deep_blue(BLUE);
2008-4-22
{249}
(#4408632@0)