2016-11-21 83 views
0

我真的很感謝我的代碼的一些幫助。在提交表單數據後,我想將提交者重定向到我選擇的任何頁面。如何在提交後重定向

如果您將代碼插入以下鏈接「http://www.w3schools.com/html/tryit.asp?filename=tryhtml_default」並按照提示進行操作,您會看到何時進入「約會摘要」頁面,頂部有文本,指示用戶「點擊此處付款存款」。我遇到的問題是人們沒有點擊要重定向的文本。我想爲用戶提交表格又名時間表預約後約會概要頁面幾秒鐘可見,然後用戶被自動重定向到我選擇的網頁。我也不希望文本「CLICK + HERE + TO + PAY + YOUR + DEPOSIT」在帳戶摘要中顯示,只是在提交表單後重定向。

下面是代碼:

<iframe id="schedulista-widget-00" 
    src="https://www.schedulista.com/schedule/neecostylez? 
    mode=widget&rt_url=http://www.neecostylez.com/product-page/b58af64e-f174-6c25-a524- 
    6388b7ddd6b7&rt_text=CLICK+HERE+TO+PAY+YOUR+DEPOSIT" ="true" 
    frameborder="0" scrolling="no" width="100%" height="900px"> 
    </iframe><script id="schedulista-widget-script-00" type="text/javascript" 
    src="https://www.schedulista.com/schedule/neecostylez/widget.js"></script> 

這是我想它重定向過AFTER用戶(提交的表單)又名預定他們的任命。 http://www.neecostylez.com/product-page/b58af64e-f174-6c25-a524-6388b7ddd6b7

回答

0

只需加入到這個如果其他人正在尋找相同的答案,則無法爲SCHEDULISTA WIDGET工作。這是因爲交叉來源的政策和schedulista不允許你訪問他們的最終代碼。

下面的解決方案只有在您有權訪問iframe代碼時纔有效。

我們添加一個事件觸發條件的onClick到在iframe提交按鈕,觸發來自IFRAME父window.Calling funtion一個funtion使用下面的提交按鈕:

parent.redirect_function(); 

在父窗口了這一點我們可以爲重定向前的等待時間添加設置的超時時間(重新加載iframe的url)。

function redirect_function(){ 
setTimeout(function(){ 
document.getElementById('myframe').src = 'http://www.test.com'; 
}, 3000); 
} 



/* IFrame */ 

<form method="post" id="myform" name="myform" action="/" > 
<input type="text" name="input1" value="2073809442" /> 
<input type="text" name="input2" value="1" /> 
<input type="submit" name="submit" value="submit" onClick="return parent.redirect_function();" /> 
</form> 

/* Script in parent window */ 

    function redirect_function(){ 
    setTimeout(function(){ 
    document.getElementById('myframe').src = 'http://www.exsamp.com'; 
    }, 3000); 
    } 


/* Html for iframe in parent window */ 

<iframe frameborder="0" scrolling="no" width="530" height="298" 
    src="iframe.html" name="myframe" id="myframe"> 
    <p>iframes are not supported by your browser.</p> 
</iframe><br /> 
+0

你好,非常感謝你的回覆。我是否只需將此信息複製並粘貼到我的iframe正文中即可使用?對於所有的問題,我很抱歉,我對編碼不太瞭解。 –

+0

所以函數進入父窗口,然後添加onClick =「return parent.redirect_function();」到你的iframe中的預約按鈕,(提交按鈕,讓你到賬戶摘要頁面) –

+0

嘿,我們可以通過電子郵件發言嗎? –