2014-10-09 85 views
0

我遇到的問題是阻止鏈接啓動新頁面並將其href值加載到iframe中。客戶端站點正在使用healcode提供小部件來安排健身課程的服務。查看此page當您在小部件加載後單擊註冊按鈕時,它會打開一個新頁面。客戶想要的是在相同頁面或彈出窗口中打開該鏈接。我嘗試了所有我能想到的。我已經使用jQuery,fancybox等。在iframe中打開healcode鏈接

這裏是代碼IM使用 screenshot

我認爲問題在於,我的內聯腳本在小部件腳本完成之前加載呈現計劃html。

我知道這是可能的,因爲this site使用相同的小部件,並且它們的註冊將打開同一頁面上的覆蓋幀中的鏈接。

請大家澄清一下。

UPDATE:

<html> 
 
\t <head> 
 
\t \t <title>Test</title> 
 
\t </head> 
 
\t <body> 
 

 

 
<iframe id="openViewHere" width="500px" height="500px" src="" ></iframe> 
 

 
<script type="text/javascript"> 
 
    healcode_widget_id = "7696499e81"; 
 
    healcode_widget_name = "schedules"; 
 
    healcode_widget_type = "mb"; 
 
    document.write(unescape("%3Cscript src='https://www.healcode.com/javascripts/hc_widget.js' type='text/javascript'%3E%3C/script%3E")); 
 
    // Healcode Schedule Widget for Iyengar Yoga Association of Greater New York : Brooklyn Daily Class Schedule 
 
</script> 
 
<noscript>Please enable Javascript in order to get <a href="https://www.healcode.com" target="_blank">HealCode</a> functionality</noscript> 
 

 

 

 
<script src="https://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script> 
 
<script type="text/javascript"> 
 
     
 
\t $(".signup_now").click(function(){ 
 
\t \t \t 
 
\t \t var url = $(this).attr("href"); 
 
\t \t \t 
 
\t \t $("#openViewHere").attr("href",url); 
 
\t \t \t 
 
\t \t \t 
 
\t \t \t 
 
\t \t return false; 
 
\t }); 
 

 
</script> 
 

 

 

 
\t 
 
\t </body> 
 
</html>

+0

請提供小提琴 – ProllyGeek 2014-10-09 01:16:30

+0

這是http://jsfiddle.net/f2sfzeg9/4/ – leafartist 2014-10-09 01:45:57

+0

您的註冊按鈕在哪裏? – ProllyGeek 2014-10-09 01:55:01

回答

1

只需使用此代碼:

$(document).ready(function(){ 


    $("body").on('click',".signup_now",function(e){ 

     $(this).attr("target","_self") 

      }) 

}) 

知道windows.ready()可能會火,而插件腳本仍在增加元素dynamicaly這就是爲什麼聽衆不工作,你必須通過已經加載的父(如「身體」)訪問元素。

+0

不客氣。 – ProllyGeek 2014-10-09 03:47:15