UWInfo Blog
發表新文章
[Join] | [忘記密碼] | [Login]
搜尋

搜尋意見
文章分類-darren
[所有文章分類]
  • ASP.NET (24)
  • ASP.NET2.0 (4)
  • ASP.NET4.0 (13)
  • JavaScript (17)
  • jQuery (5)
  • FireFox (2)
  • UW系統設定 (2)
  • SQL (7)
  • SQL 2008 (3)
  • mirror (0)
  • SVN (2)
  • IE (3)
  • IIS (6)
  • IIS6 (0)
  • 閒聊 (1)
  • W3C (4)
  • 作業系統 (3)
  • C# (14)
  • CSS (0)
  • FileServer (0)
  • HTML 5 (7)
  • CKEditor (0)
  • UW.dll (9)
  • Visual Studio (2)
  • Browser (2)
  • SEO (0)
  • Google Apps (1)
  • 網站輔助系統 (1)
  • DNS (0)
  • SMTP (3)
  • 網管 (5)
  • 社群API (3)
  • SSL (1)
  • App_Inventor (0)
  • URLRewrite (1)
  • 開發工具 (2)
  • JSON (0)
  • Excel2007 (0)
  • 試題 (0)
  • LINQ (0)
  • bootstrap (0)
  • Vue (0)
  • IIS7 (2)
  • foodpanda (0)
  • 編碼 (0)
  • 資安 (3)
  • Sourcetree (0)
  • MAUI (0)
  • CMD (0)
  • my sql (1)
所有文章分類
[darren的分類]
  • ASP.NET (48)
  • ASP.NET2.0 (15)
  • ASP.NET4.0 (34)
  • JavaScript (49)
  • jQuery (26)
  • FireFox (4)
  • UW系統設定 (3)
  • SQL (39)
  • SQL 2008 (25)
  • mirror (4)
  • SVN (4)
  • IE (9)
  • IIS (20)
  • IIS6 (1)
  • 閒聊 (7)
  • W3C (6)
  • 作業系統 (9)
  • C# (24)
  • CSS (12)
  • FileServer (1)
  • HTML 5 (11)
  • CKEditor (3)
  • UW.dll (13)
  • Visual Studio (16)
  • Browser (8)
  • SEO (1)
  • Google Apps (3)
  • 網站輔助系統 (4)
  • DNS (5)
  • SMTP (4)
  • 網管 (11)
  • 社群API (3)
  • SSL (4)
  • App_Inventor (1)
  • URLRewrite (2)
  • 開發工具 (6)
  • JSON (1)
  • Excel2007 (1)
  • 試題 (3)
  • LINQ (1)
  • bootstrap (0)
  • Vue (3)
  • IIS7 (3)
  • foodpanda (2)
  • 編碼 (2)
  • 資安 (3)
  • Sourcetree (1)
  • MAUI (1)
  • CMD (1)
  • my sql (1)
最新回應
  • IIS ARR (reverse proxy) 服務安裝
    ...more
  • UW DB 元件罕見的錯誤
    我之前好像也遇過, 考慮改一下 pg 的程式....more
  • UW DB物件 GetAllDataFromBaseTableWithCache 會嚴重影響效能
    我把它拿掉了....more
  • UW DB物件 GetAllDataFromBaseTableWithCache 會嚴重影響效能
    好, 把它拿掉.....more
  • 使用 facebook JS SDK 的心得筆記
    FB.login 沒有任何反應~ 不知道怎解決...more
  • IIS Server SSL 升級方式
    更新一版 reg 可以變 A...more
  • 防止 event 往上傳的終極方法
    eee...more
  • IIS Server SSL 升級方式
    Cool......more
  • UNT流量異常追蹤紀實
    有做 Request 的來源 IP 分析嗎 ? 說不定會有其它的發現.....more
  • facebook 網頁分享 Debug 模式
    Header 裡面的兩個 tag.. <meta property="og:i...more
標籤
  • 0.6avnc
  • sys_log
  • kerry
  • Rm8noQZH
  • Block
  • ordermain[
  • web.
  • 桌面
  • 指令
  • 4728-4728
  • cookie
  • iTextSharp
  • [u2]
  • if ORDER B
  • MSDTC
  • 8471-8405
  • 58
  • svg
  • 103.234.81
  • primary
  • let
  • table
  • js UNION A
  • -2173
  • 636
  • ctrl
  • AD
  • 332
  • 130
  • -5461
  • Shopee
  • 242
  • 150
  • EN
  • 22
  • fredck.fck
  • 56
  • contains,
  • ti
  • 992
  • 9604
  • jquery XSS
  • 1342121121
  • 行號
  • json212112
  • SU
  • WU
  • 帳號
  • 88.4raJb
  • 查看資料庫最耗時的S
搜尋 結果:
解決 jquery XSS問題,升級到 3.5 版以上之相關處理
最近因為資安公司要求,要把 jQuery 升級到最新版
網路查了一下,似乎 3.5 版以後, XSS 才算是改善很多

目前最新版本是 3.7.0,對於原本就使用 3 以上版本專案影響就不大,所有 function 沿用上沒有問題
但是有些舊專案使用 2.X 甚至 1.X 升級到 3.7.0 版之後就會有些功能掛掉

經測試,首當其衝的就是 $(window).load 不能使用,更精準一點應該是 .load() 不能使用
檢查 jquery 過期網頁 https://api.jquery.com/category/deprecated/
發現 .load() 是 1.8 版以後 deprecated,但我 2.2.4 用很久用爽爽
我想應該是 jquery 為了相容問題,一直到跨版本才真的拿掉
也就是 1.X 宣告 deprecated 的功能,到 3.X 才真的移除
(請看附圖)
所以我就鴕鳥的找 1.X  deprecated 然後可能會用的 function 處理
(若有 tag "Removed" 就是已移除,這樣找比較快)
.andSelf()
.live()
.die()
.error()
.load()
.unload()
.size()
.toggle()

大致上專案搜尋字串應該就能處理
但有些可能是其他第三方 jquery物件 例如 jquery-ui ,會用到以上功能
這時可能要去該物件看有無對應升級版
 
More...
darren, 2023/7/20 上午 11:08:33
jQuery 之 event.originalEvent
有時候用 jQuery 使用 event 物件時,會發現有些特殊事件的 property 抓不到 (undefined)
例如
mousewheel --> event.wheelDelta 
drop --> event.dataTransfer
touchstart --> event.touches[0].pageX
原因是 jQuery 的 event 只會包裝一般的屬性,特別的屬性要使用 event.originalEvent 去抓
event.originalEvent 是瀏覽器原生的 event

It's also important to note that the event object contains a property called originalEvent, which is the event object that the browser itself created. jQuery wraps this native event object with some useful methods and properties, but in some instances, you'll need to access the original event via event.originalEvent for instance. This is especially useful for touch events on mobile devices and tablets.

所以開發時當有些特殊屬性抓不到時,可以考慮用 event.originalEvent 去抓看看

    // 這是用滾輪放大縮小圖片 (此範例firefox不支援)
    $("#imgProductBig").bind("mousewheel", function (ev) {
        var delta = ev.originalEvent.wheelDelta > 0 ? 1 : -1;
        if (delta > 0 && zoomValue < 150) {
            zoomValue += 10;
        }
        else if (delta < 0 && zoomValue > 50) {
            zoomValue -= 10;
        }
        $(this).css("zoom", zoomValue + '%');
        return false;
    });


 
More...
darren, 2015/4/21 下午 12:03:35
左邊 Menu 當scroll時固定位置的方法 js
這個活動頁左邊 menu 要固定位置 但是不能跑出框框外面
http://www.shopunt.com/tch/event/2014-naked-truth-cc-cream/

所以需要處理scroll物件


<div id="menuContainer">
  <div id="menu">
    <ul>
      <li>menu1</li>
      <li>menu2</li>
    </ul>
  </div>
  <div> ...長內容.... </div>
</div>

js
        var __ContainerHeight = 5000;
        var __ContainerTop = 160;
        var __MenuHeight = 550;
        var __FixedTop = 20;

        $(window).load(function () {

            __ContainerHeight = $("#menuContainer").height();
            __ContainerTop = $("#menuContainer").offset().top;
            __MenuHeight = $("#menu").height();

            $("#menu").css({ "top": __FixedTop + "px", "position": "absolute" });
            $(window).scroll(function () {
                var scrolls = $(this).scrollTop();
                //console.log(scrolls);
                if (scrolls < __ContainerTop) {
                    $("#menu").css({ "top": __FixedTop + "px", "position": "absolute" });
                }
                else if ((scrolls + __MenuHeight + __FixedTop) > (__ContainerHeight + __ContainerTop)) {
                    $("#menu").css({ "top": (__ContainerHeight - __MenuHeight) + "px", "position": "absolute" });
                }
                else {
                    $("#menu").css({ "top": __FixedTop + "px", "position": "fixed" });
                }
            });

        });

 
More...
darren, 2014/6/20 下午 02:03:01
使用 ajax 傳送有 textarea 資料時要注意處理斷行符號
最近常使用 jQuery ajax form 處理表單,意外發現使用ajax form 傳送的 textarea 資料斷行符號只會有 vbLf (\n)
而非我們一般認知的 vbCrLf (\r\n)

原因在於 javascript 變數處理 string 資料,斷行文字只有 \n 不會是 \r\n
ajax form 物件在轉換 form data 到 XHR 的 post data 時,自然就把 \r 給濾掉了
所以 Server 會端收到僅有 \n 的斷行符號

這樣使用 UW.TextFns.ContentToHtml 就不會產生 "<br>" 了
因為這支程式是使用 vbCrLf 去取代成 <br>

 
More...
darren, 2014/1/3 下午 07:39:47
Jquery Ajax error 之 parsererror 訊息
最近弄ajax 發現一個現象 先記起來一下
當 ajax dataType 是 json 時
            $.ajax({
                cache: false,
                data: "fun=SetAsBestAnswer&aid=" + articleId + "&rid=" + replyId,
                dataType: "json",
                success: function (objData, strTextStatus) {
                ...........

response的文字它會自動轉為物件,是以 jQuery.parseJSON 處理轉為此範例的 objData
但是有時會發生 parsererror 的錯誤
後來我發現是因為json 的 key 值必須要雙引號包起來才可以
然後字串內容也不能有斜線+單引號 \'   所以以下三者都是會失敗的
{test: "I'm a student."} 
{'test': "I'm a student."}
{"test": "I\'m a student."}

以下兩個都是OK的
{"test": "I'm a student."} --> OK
{"test": "I\u0027m a student."} --> OK


More...
darren, 2012/8/17 上午 11:39:28
~ Uwinfo ~