Javascript etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
Javascript etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

15 Temmuz 2010 Perşembe

ExtJs.Window için Sürükle Bırak (Drag'n Drop) Düzeltmesi

Bir süredir ExtJS ve diğer bazı JS kütüphanelerinden bolca kullanıldığı bir ajax ekranı ile uğraşmaktaydım. Şöyle bir problemle karşılaştım, ekranda bir çok panel açık olduğunda bir Ext.Window açtığımızda Ext.Window'u sürükle bırak yaparken aşağıdaki ekranlarla da etkileşim sürdüğü için takılmalar oluyordu.

Bu sorunu Ext.Window'u "modal pane" olarak yaparak (modal:true) çözebilirdim ama window açıkken arka plan ile etkileşimi kaybetmek de istemiyordum. Bu nedenle ben de şöyle bir çözüm düşündüm: Ext.Window sürükle bırak yapılırken arka plan modal pane haline gelsin (opacity verilen bir mask div'i sayesinde), sürükle bırak tamamlanınca da eski haline dönsün.

    ...
    <div class="ext-el-mask" id="ext-modal-mask" 
    style="display: none; width: 100%; height: 100%; z-index: 9000;"></div>
    ...
    var originalStartDrag = Ext.Window.DD.prototype.startDrag;
    var originalEndDrag = Ext.Window.DD.prototype.endDrag;
    Ext.override( Ext.Window.DD, {
        startDrag: function() {
    Ext.get('ext-modal-mask').show();
    originalStartDrag.apply(this, arguments);
        },
        endDrag: function() {
         Ext.get('ext-modal-mask').hide();
         originalEndDrag.apply(this, arguments);
        }
    } );

16 Haziran 2010 Çarşamba

BFB (The Prehistoric Time Before Firebug)

A quote from Java World Article:
Web development arguably has two distinct eras: BFB -- the (prehistoric) time before Firebug when we learned the limits of alerts -- and the modern AFB (after Firebug) when we found that we can once again spend quality time with our families. Firebug truly is Web development evolved. Developing a Web application without using Firebug is like coding Java in vi -- it can be done, but it's just not worth the pain.

Kaynak: Ajax: Tools of the trade - "A rich array of tools for the modern JavaScript developer"

10 Temmuz 2009 Cuma

JQuery Visualize

Scott Jehl tarafından yayınlanan JQuery eklentisi JQuery Visualize sayesinde HTML table'ındaki verilerden çok güzel grafikler oluşturmanız mümkün. Üstelik bunu basit bir $('table').visualize(); koduyla yapabiliyorsunuz.

JQuery Visualize

2 Temmuz 2009 Perşembe

Yuvarlak Köşeler

Jquery'nin yuvarlak köşeler oluşturmanızı sağlayan güzel bir eklentisi (rounded corners plug-in ) var. Bunun sayesinde resimlerin bile köşelerini yuvarlatmak mümkün.

Gerekli Dosyalar:


Ayrıntılı Bilgi İçin Tıkla


13 Ekim 2008 Pazartesi

JQuery

Javascript kütüphaneleri bu aralar çok moda. JQuery isimli bi javascript kütüphanesi galiba prototype.js'nin pabucunu dama atmaya aday. Burdun buradan inceleyin:

http://jquery.com/

Burda da çok güzel bilgiler var:

http://www.eburhan.com/jquery-dunyasina-adim-atiyoruz/

24 Eylül 2008 Çarşamba

Lightbox JS

LightBox JS, web sitenizde resimlerin büyük halini yeni bir sayfa açmadan layer olarak göstermenizi sağlayan bir script uygulamasıdır. gerçekte kullanımı çok kolay ve pratik bir uygulama. Aşağıdaki linklerden ayrıntılı bilgiye erişebilirsiniz:

Kaynak-1
Kaynak-2

26 Ağustos 2008 Salı

Filtering JavaScript to Prevent Cross-Site Scripting

Yaptığım bir sitenin cross-site-scripting (XSS) saldırılarına açık olduğunu farkettim. XSS açığında, eğer saldırgan HTML kodlarının arasına istemci tabanlı kod gömerse, kullanıcının tarayıcısında istediği istemci tabanlı kodu çalıştırabiliyor.

Mesela aşağıdaki şekildeki request'e göre işlem yapan bir site düşünelim:
http://www.benimsitem.com/haber.html?id=156
Açık bulunanan site name değişkenini okuyup hiçbir filtreleme yapmadan sayfaya yazdırıyorsa, o zaman bu değerde istenilen kod çalıştırılabilir.
http://www.benimsitem.com/haber.html?id=<script>alert(document.cookie)</script>
Genelde cross site scripting açıkları, saldırganın sistemi deneme-yanılma yaparak bulması ile ortaya çıkıyor. Açığın bulunması ile saldırgan, başka bir domainden, açığın bulunduğu domain ve sayfanın bilgilerini, session bilgilerini ve diğer obje değerlerini çalmasına olanak sağlar. (1)

Peki bu açığı nasıl kapatabiliriz? Web Programlama yapan biri olarak kullanıcıdan gelen hiçbir girdiye güvenmemelisiniz ve gelen her request'i server tarafında filtrelemelisiniz. Eğer request'ten gelen parametrede özel karakterler varsa ( SCRIPT tag'i gibi ), bunları reddetmeli veya özel bir metodla bu özel karakterleri değiştirmelisiniz. Mesela ben bunun için şöyle bir java metodu yazdım:



public static String filterForSpecialCharacters( String inputStr ){

String outputStr = inputStr + "";

outputStr = outputStr.replace ( "'", " " );
outputStr = outputStr.replace ( "\"", " " );
outputStr = outputStr.replace ( "%", " " );
outputStr = outputStr.replace ( ";", " " );
outputStr = outputStr.replace ( "(", " " );
outputStr = outputStr.replace ( ")", " " );
outputStr = outputStr.replace ( "&", " " );
outputStr = outputStr.replace ( "+", " " );
outputStr = outputStr.replace ( "<", " " );
outputStr = outputStr.replace ( ">", " " );

return outputStr;

}

Gördüğünüz gibi, kullanıcıdan gelen input'u kullanmadan önce bu metoda gönderirseniz. Özel karakterler filtrelenerek, size güven içinde kullanabileceğiniz değişkeni geri döndürür.

Bu XSS açığı için PHP, ASP gibi dillerde kullanılabilecek belirli kütüphaneler var ama java'da ne yazık ki böyle standart bir kütüphane yok. Ancak aşağıdaki adreste XSS ataklarına karşı yazılmış bir kütüphane Java class'ı var: BAKINIZ




Cross-site scripting hakkında ayrıntılı bilgi edinmek isteyenlere aşağıdaki bilgileri derledim. Umarım faydalı olur.

1- Introduction

Cross-Site Scripting is one of the main problems of any Web-based service. Since Web browsers support the execution of commands embedded in Web pages to enable dynamic Web pages attackers can make use of this feature to enforce the execution of malicious code in a user’s Web browser. JavaScript is the most commonly used command language in this context. If misused, stealing of authentication information may be possible thus allowing attackers to act under a stolen identity. The attack is based on the possibility to insert malicious JavaScript code into pages shown to other users. Therefore filtering malicious JavaScript code is necessary for any Web application. This paper describes the overall problem and elaborates on the possibilities to filter JavaScript in Web applications. Also a filtering architecture is presented that allows Web application developers to filter JavaScript depending on the application need to reduce the danger of successful Cross-Site Scripting attacks. (1)

2 - Avoiding an Attack

2.1 - Filtering

The basis of this approach is never trust user input and always filter metacharacters ("special" characters) that are defined in the HTML specification. Each input field, including link parameters will be validated for script tags. When found and dependent on the context, the input will be rejected and thus prevent the malicious HTML from being presented to the user. (3)

2.2-) Encoding

Cross-site scripting attacks can be avoided when a Web server adequately ensures that generated pages are properly encoded to prevent unintended execution of scripts. Each character in the ISO-8859-1 specification can be encoded using its numeric entry value. Server side encoding is a process where all dynamic content will go through an encoding function where scripting tags will be replaced with codes in the chosen character set. Generally speaking, encoding is recommended because it does not require you to make a decision about what characters could legitimately be entered and need to be passed through. Unfortunately, encoding all untrusted data can be resource intensive and may have a performance impact on some Web servers.


For More Information:

http://www.ibm.com/developerworks/tivoli/library/s-csscript/
http://www.developer.com/java/article.php/883381






Citation
-----------
(1) http://tr.wikipedia.org/wiki/Cross_site_scripting
(2) Filtering JavaScript to Prevent Cross-Site Scripting - Created by:
EUROSEC GmbH Chiffriertechnik & Sicherheit
(3) http://www.ibm.com/developerworks/tivoli/library/s-csscript/




19 Kasım 2007 Pazartesi

Page Expire Problem When Browser's Back Button is Clicked

PROBLEM:

As a result of a search form submission, results are displayed as links. The user clicks any links and goes to that page. When back button is pressed, browser gives an error.


In detail,

1. User submits an HTML form that does a search.
2. User sees a list of search results, each hyperlinked to a details screen.
3. User clicks one of the "details" hyperlinks.
4. User sees the details screen.
5. User clicks browser's "Back" button to return to the screen in Step 2.
6. Browser gives confusing message about having to resubmit POST data. In Firefox this is a dialog box with OK/Cancel, and IE this is a white screen with the message:

"Warning: Page has Expired The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you. To resubmit your information and view this Web page, click the Refresh button."

SOLUTION:

Handle the form inside javascript, and submit search using request parameters.

Not a Form, a text input field and a link:

SEARCH LINK
Javascript Code:function ProcessSearchSubmit() {
linkToRedirect="/search.ovt?results=allResults&searchInput=";
if ( document.getElementById('searchInputId') ) {
linkToRedirect += document.getElementById('searchInputId').value;
}
setTimeout( "window.location.href = linkToRedirect", 0 );
}

Window.location.href not working in IE for every page

There is a problem about javascript redirect in Internet Explorer. I couldn't redirect to another page in IE using

window.location.href = url;

This command gets executed (proofed with alert messages) but nothing happens. Firefox acts like expected but i couldn't get it work in IE.

I have finally found the solution after some google search.

RedirectUrl = url;
setTimeout( "window.location.href = RedirectUrl", 0 );

Another solution says that if you set this from the window.location.href in a Javascript function, is enough to return false. Check this out: IE bug.