×

Loading...
Ad by
  • 予人玫瑰,手有余香:加拿大新天地工作移民诚聘求职顾问&行业导师!
Ad by
  • 予人玫瑰,手有余香:加拿大新天地工作移民诚聘求职顾问&行业导师!

很奇怪的需求。考虑过iframe没有?

root 页面:

sn=xxxxxx

<iframe src=a.aspx>


在a.aspx里任何左键点击都返回到自身,可以拿到parent.sn . 右键打开新窗口,没有parent.sn, 就从新生成一个sn,生成一个带iframe的新页。 不过页面的内容一定是ajax了。
Report

Replies, comments and Discussions:

  • 工作学习 / 学科技术讨论 / 如何在网页里放置一个值,这个值只针对一个窗口,如果打开另外一个窗口,那个值需要有相应的变化呢?
    其实就象赋予浏览器一个 identifier 那样

    问题是有很多不同的情况要处理:
    1,比如打开window A,B 分别打开那个网页,那个ID在 A,B 里应该完全不一样的值
    2,在 A 用鼠标右键打开 B
    3,在 A 用鼠标左键打开 B
    4,IE 里面可以 clone 一个 B
    5,FF, IE7, OPERA 里面每个 TAB 都需要有不同的值

    有什么好的想法没有?
    已经在考虑了很多天,不好解决
    • 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?
      • 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
    • 很奇怪的需求。考虑过iframe没有?
      root 页面:

      sn=xxxxxx

      <iframe src=a.aspx>


      在a.aspx里任何左键点击都返回到自身,可以拿到parent.sn . 右键打开新窗口,没有parent.sn, 就从新生成一个sn,生成一个带iframe的新页。 不过页面的内容一定是ajax了。
      • 好主意!iframe 是不行的,不过我发现用一个 invisible frame 其实是可以保证声称一个 unique identifier for a browser
        • 其实不如干脆diable right click, 所有的页面内link都用 href='javascript:openpage()' 来做,右键根本打不开。
          我的理解是从server side, 左键和右键打开的页面是没有任何区别的, 所以一定是client side javascript来判断是否是新窗口。这样页面的内容也一定要由javascript 来控制显示,所以Ajax是必然的。

          tab index 之类跨浏览器有问题, 页面自身也没有任何id, 所以从parent页面入手是可行的。我不明白你如何用隐藏frame, 在隐藏frame之外的任何连接,你还是么办法区分左键和右键打开啊。
          • 那个我早就问过了,很不幸是一个 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,正在考虑还有什么别的情况
    • there is a way, you can store the id inside database, but might not a good solution for a public webpage.
    • 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.
      • 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.
        • It depends. If you use .NET, you can tell on server side.
          • 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?
            • Actually, when you use Ctrl + N to start the page itself
              it 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.