2016年12月13日 星期二

[javascript] 掃描某個ID的 Element


javascript 抓某個ID值的 Element

            for(i=0; i<document.getElementsByTagName("div").length; i++)
            {
                try {
                    if(document.getElementsByTagName("div")[i].getAttribute("id") == Today)
                    {
                        var Field = document.getElementsByTagName("div")[i];
                    }
                }
                catch(e){}

            }

[javascript] 解決【您正在檢視的網頁嘗試要關閉視窗,您是否要關閉此視窗】



參考:https://social.msdn.microsoft.com/Forums/zh-TW/1649d31b-43c6-4b76-8d57-40b36aaf9d27


當使用javascript呼叫window.close();要關閉時有時候會出現

"您正在檢視的網頁嘗試要關閉視窗,您是否要關閉此視窗?"


void(window.open('','_parent',''));
window.close();


2016年10月17日 星期一

[C#] 取得網址 Using Request.Url to find specific parts of the web page's URL



參考:http://www.codepal.co.uk/show/Using_RequestUrl_to_find_specific_parts_of_the_web_pages_address




Request.Url.GetLeftPart(UriPartial.Authority) http://www.codepal.co.uk:123
Request.Url.GetLeftPart(UriPartial.Path) http://www.codepal.co.uk:123/RequestUri.aspx
Request.Url.GetLeftPart(UriPartial.Query) http://www.codepal.co.uk:123/RequestUri.aspx?queryStringVal=Hello
Request.Url.GetLeftPart(UriPartial.Scheme) http://
Request.Url.ToString http://www.codepal.co.uk:123/RequestUri.aspx?queryStringVal=Hello
Request.Url.AbsolutePath /RequestUri.aspx
Request.Url.AbsoluteUri http://www.codepal.co.uk:123/RequestUri.aspx?queryStringVal=Hello
Request.Url.Authority www.codepal.co.uk:123
Request.Url.GetComponents(UriComponents.AbsoluteUri, UriFormat.SafeUnescaped) http://www.codepal.co.uk:123/RequestUri.aspx?queryStringVal=Hello
Request.Url.GetComponents(UriComponents.Fragment, UriFormat.SafeUnescaped)
Request.Url.GetComponents(UriComponents.Host, UriFormat.SafeUnescaped) www.codepal.co.uk
Request.Url.GetComponents(UriComponents.HostAndPort, UriFormat.SafeUnescaped) www.codepal.co.uk:123
Request.Url.GetComponents(UriComponents.HttpRequestUrl, UriFormat.SafeUnescaped) http://www.codepal.co.uk:123/RequestUri.aspx?queryStringVal=Hello
Request.Url.GetComponents(UriComponents.KeepDelimiter, UriFormat.SafeUnescaped)
Request.Url.GetComponents(UriComponents.Path, UriFormat.SafeUnescaped) RequestUri.aspx
Request.Url.GetComponents(UriComponents.PathAndQuery, UriFormat.SafeUnescaped) /RequestUri.aspx?queryStringVal=Hello
Request.Url.GetComponents(UriComponents.Port, UriFormat.SafeUnescaped) 123
Request.Url.GetComponents(UriComponents.Query, UriFormat.SafeUnescaped) queryStringVal=Hello
Request.Url.GetComponents(UriComponents.Scheme, UriFormat.SafeUnescaped) http
Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped) http://www.codepal.co.uk:123
Request.Url.GetComponents(UriComponents.SerializationInfoString, UriFormat.SafeUnescaped) http://www.codepal.co.uk:123/RequestUri.aspx?queryStringVal=Hello
Request.Url.GetComponents(UriComponents.StrongAuthority, UriFormat.SafeUnescaped) www.codepal.co.uk:123
Request.Url.GetComponents(UriComponents.StrongPort, UriFormat.SafeUnescaped) 123
Request.Url.Host www.codepal.co.uk
Request.Url.HostNameType.ToString Dns
Request.Url.OriginalString http://www.codepal.co.uk:123/RequestUri.aspx?queryStringVal=Hello

2016年9月24日 星期六

[系統] 換新硬碟如何把舊硬碟的瀏覽器資料救回 ie、firefox、chrome



轉自:http://www.twhnp.com/dis/forum.php?mod=viewthread&tid=171758


弄外接碟即可,只要能讀的到應就能找回
原系統是XP?win7?...假設是win7
IE,我的最愛:找到外接碟中 \Users\<你的帳號名>\下Favorites資料夾,把它複製到C:\Users\<新機帳號名>\下,覆蓋即可。
FireFox,書籤:在外接碟中,找這個路徑
   \Users\<你的帳號名>\AppData\Roaming\Mozilla\Firefox\Profiles\<8位數亂數>.default\bookmarkbackups
把這個資料夾複製到C:\下相同位置下(覆蓋它),前提要先安裝firefox
再來就參考這篇復原FireFox備份與回復書籤
Chrome,書籤:在外接碟中,找這個路徑
\Users\<你的帳號名>\AppData\Local\Google\Chrome\User Data\Default
把這個資料夾下的bookmark和bookmarks.bak複製到C:\下相同位置下(覆蓋它),前提要先安裝Chrome

PS. Chrome和Firefox建議可使用指定帳號同步的功能,這樣不論換什麼電腦,只要使用該帳戶登入chrome或firefox,這樣所有的設定、附加元件及有記憶的帳密都可以快速復原。


2016年7月20日 星期三

[MSSQL] 資料庫主體在資料庫中擁有 結構描述 且無法卸除 (Microsoft SQL Server, 錯誤: 15138)



參考:http://dog0416.blogspot.tw/2015/04/databasemssql-microsoft-sql-server-15138.html


在Microsoft SQL Server Managment Studio ,展開安全性 -> 使用者,滑鼠右鍵點選使
用者,選擇刪除。

出現刪除視窗後,點選確定,出現下列錯誤訊息。

錯誤訊息:
資料庫主體在資料庫中擁有 結構描述 且無法卸除 (Microsoft SQL Server, 錯誤: 15138)

Error message:
The database principal owns a schema in the database, and cannot be dropped. (Microsoft SQL Server, Error: 15138).

我們使用下列指令,將所有在此資料庫的結構描述指派給dbo,該資料庫使用者物件即可移除。

ALTER AUTHORIZATION ON SCHEMA::[無法刪除的使用者名稱] TO [dbo]

2016年4月7日 星期四

[c#] (413) Request Entity Too Large


轉自:http://karatejb.blogspot.tw/2015/04/troubleshooting-wcf-error-413-request.html


使用wcf服務時出現以下錯誤

(413) Request Entity Too Large

原來是WCF預設單筆Message size 65KB 避免DOS攻擊。
當超過此上限時,便會引發此錯誤。
這時候需再client端和wcf服務端的config加上以下設定


WCF的Config
<configuration>
<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="2147483647"
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647">
          <readerQuotas maxDepth="32"
                        maxArrayLength="2147483647"
                        maxStringContentLength="2147483647"/>
        </binding>
      </basicHttpBinding>
    </bindings>
</system.serviceModel>
</configuration>



Client的Config檔

<configuration>
<system.serviceModel>

      <bindings>
          <basicHttpBinding>
              <binding name="BasicHttpBinding_IMonitorService"
                        maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"receiveTimeout="00:30:00" sendTimeout="00:30:00"/>
          </basicHttpBinding>
          <netNamedPipeBinding>
              <binding name="NetNamedPipeBinding_IMonitorService">
                  <security mode="None" />
              </binding>
          </netNamedPipeBinding>
       
      </bindings>
</system.serviceModel>
</configuration>



2016年3月22日 星期二

[C#] NLog 建置筆記






        /// <summary>
        /// NLog 紀錄
        /// </summary>
        public static NLog.Logger NLogger = NLog.LogManager.GetCurrentClassLogger();





* 抓取Session的值

參考 https://github.com/NLog/NLog/wiki/AspNetSession-layout-renderer

程式:
Session["user"] = new UserInfo { Name= "johnDoe", Id = 100};

nlog config設定 :
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <targets>
        <target name="logfile" xsi:type="File" fileName="file.txt" />
    </targets>

    <rules>
        <logger name="*" minlevel="Info" writeTo="logfile" layout="${aspnet-session:Variable=User.Name:EvaluateAsNestedProperties=true}/>
    </rules>
</nlog>



發生【LayoutRenderer cannot be found: 'aspnet-request'】的錯誤時,
需安裝 NLog.Extended.dll 可擴增功能
http://kevintsengtw.blogspot.tw/2011/10/nlog-advanced-net-logging-3.html




Session格式範例
http://nlog-project.org/documentation/v2.0.1/html/T_NLog_LayoutRenderers_AspNetSessionValueLayoutRenderer.htm


You can set the value of an ASP.NET Session variable by using the following code:

C#
HttpContext.Current.Session["myvariable"] = 123;
HttpContext.Current.Session["stringvariable"] = "aaa BBB";
HttpContext.Current.Session["anothervariable"] = DateTime.Now;


Example usage of ${aspnet-session}:

${aspnet-session:variable=myvariable} - produces "123"
${aspnet-session:variable=anothervariable} - produces "01/01/2006 00:00:00"
${aspnet-session:variable=anothervariable:culture=pl-PL} - produces "2006-01-01 00:00:00"
${aspnet-session:variable=myvariable:padding=5} - produces "  123"
${aspnet-session:variable=myvariable:padding=-5} - produces "123  "
${aspnet-session:variable=stringvariable:upperCase=true} - produces "AAA BBB"



常用的:
${time} 時間
${asp-session:variable=String}  Session
${aspnet-request:cookie=String:serverVariable=String:queryString=Strin:item=String:form=String}
Cookie_ queryString

${basedir} 根目錄
${date} 日期+時間
${level} log等級
${newline} 換行
${shortdate} yyyy-MM-dd 日期

請參考 https://github.com/nlog/NLog/wiki/Layout%20Renderers


-------------------------------------


NLog config設定的變數宣告方式:

${APName}_${mdc:item=DateName}


程式碼:

            //以時間來命名 NLog 檔名,需在NLog.config 宣告 ${mdc:item=DateName} 變數來使用
            NLog.MappedDiagnosticsContext.Set("DateName", DateTime.Now.ToString("HH-mm-ss"));





2016年1月10日 星期日

[好蕉好蕉]

 

MangoHost Copyright © 2009 Cookiez is Designed by Ipietoon for Free Blogger Template