2013-05-26 59 views
0

我知道一個「黑客」,以避免後回來做一個jQuery綁定click事件跨度包裝 的img元素 但這個時候,我需要有一個HERF爲seo的目的 這一個不適合我這是ither禁用,如果我添加一個jQuery代碼return false 或它做了回發。img元素做一個回

<a id="a_ContactUs" href="contactUs.aspx"> 
    <span> 
     <img class="img_ContatUs_CssClss" src="images/HebContactUs_RCL.png" alt="contact us" title="click here" /> 
    </span> 
</a> 

是什麼讓周圍的回發問題 並且仍然使用錨的正確途徑。

+0

你有沒有注意到在你的標籤失蹤「後'a_ContactUs' – Silox

+0

@Silox就在這裏? ,謝謝雖然,不是真正的問題,因爲我的代碼沒有這個語法錯誤 – LoneXcoder

+0

你可以發佈你的相關js/jquery代碼嗎?我不知道你的問題是否理解。 –

回答

0
$(' imgID or class here ').bind('click', function (e) { 
    animatePageHide(e.target.id.split('_')[1] + ".aspx"); return false; 
    // i have used the id as the page name... say contact.aspx the id of the element to bind 
    // should be id="img_contact", then the split of the id returns the array that i take 
    // the array-element No1 which is 
    /* 
    e.target.id[0] --> img 
    e.target.id[1] --> contact 
    then i concatenated the suffix ".aspx" thats it 
    */ 
}); 

那麼功能,避免了「令人不安的眼睛」頁面刷新,同時重定向:

function animatePageHide(pageURLRedirect2) { 
    $("#DivNew_Main").fadeOut(500, function() { 
     if (pageURLRedircet2 != undefined) window.location.href = pageURLRediret2 ; 
    else window.location.href = "default.aspx"; 
    }); 

}