2011-11-02 68 views
-3
<html> 
<head> 
<script type="text/javascript"> 
function blz() 
{ 
//alert("asdf"); 
//document.getElementById("link").innerHTML='https://www.facebook.com/dialog/feed?app_id=172099656214641&link='+encodeURI(document.getElementById("product").value)+'&picture=http%3A%2F%2Fsocial.gogmat.com%2Fimages%2Flogo_03.jpg&name='+encodeURI(document.getElementById("subject").value)+'&caption=Invitation%20to%20checkout%20product%20on%20Gogmat&description=Check%20this%20product%20on%20social.gogmat.com%20now.%0A'+encodeURI(document.getElementById("message").value)+'&message=Check%20this%20product%20on%20social.gogmat.com%20now.%0A'+encodeURI(document.getElementById("message").value)+'&redirect_uri='+encodeURI(document.getElementById("redirect").value); 

document.getElementById("link").innerHTML=encodeURI("https://www.facebook.com/dialog/feed?app_id=172099656214641&link="+document.getElementById("product").value+"&picture=http%3A%2F%2Fsocial.gogmat.com%2Fimages%2Flogo_03.jpg&name="+document.getElementById("subject").value+"&caption=Invitation%20to%20checkout%20product%20on%20Gogmat&description=Check%20this%20product%20on%20social.gogmat.com%20now.%0A"+document.getElementById("message").value+"&message=Check%20this%20product%20on%20social.gogmat.com%20now.%0A"+document.getElementById("message").value+"&redirect_uri="+document.getElementById("redirect").value); 

//document.getElementById('button1').href='https://www.facebook.com/dialog/feed?app_id=172099656214641&link='+encodeURI(document.getElementById("product").value)+'&picture=http%3A%2F%2Fsocial.gogmat.com%2Fimages%2Flogo_03.jpg&name='+encodeURI(document.getElementById("subject").value)+'&caption=Invitation%20to%20checkout%20product%20on%20Gogmat&description=Check%20this%20product%20on%20social.gogmat.com%20now.%0A'+encodeURI(document.getElementById("message").value)+'&message=Check%20this%20product%20on%20social.gogmat.com%20now.%0A'+encodeURI(document.getElementById("message").value)+'&redirect_uri='+encodeURI(document.getElementById("redirect").value); 

} 
</script> 
</head> 
<body> 
<form action="#"> 
subject:<input type="text" id="subject" name="subject" value="" onkeyup="return blz()" /><br/> 
personal message:<input type="text" id="message" name="message" value="" onkeyup="return blz()" /><br/> 
select product for recommend:<input type="text" id="product" name="product" value="" onkeyup="return blz()" /><br/> 
link return:<input type="text" id="return" name="return" value="" onkeyup="return blz()" /><br/> 
<textarea id="link" name="link" rows="10" cols="40" readonly></textarea><br/> 
<a id="button1" href="" target="_blank"><img src="http://social.gogmat.com/components/com_referal/assets/images/bg_send.gif" alt="send button" /></a><br/> 
<input type="submit" /> 
</form> 
</body> 
</html> 

什麼可能是這個問題,我面對上述代碼的問題,它不顯示錨標記的textarea或href部分內的文本,我完全混淆了第一個關於這方面的時間在JavaScript。javascript的小問題

回答

0

文檔中不存在標識爲「重定向」的元素。所以這是一個JavaScript錯誤。

我已經添加缺少的元素值爲「bleh」來演示。

<html> 
<head> 
<script type="text/javascript"> 
function blz() 
{ 

//document.getElementById("link").innerHTML='https://www.facebook.com/dialog/feed?app_id=172099656214641&link='+encodeURI(document.getElementById("product").value)+'&picture=http%3A%2F%2Fsocial.gogmat.com%2Fimages%2Flogo_03.jpg&name='+encodeURI(document.getElementById("subject").value)+'&caption=Invitation%20to%20checkout%20product%20on%20Gogmat&description=Check%20this%20product%20on%20social.gogmat.com%20now.%0A'+encodeURI(document.getElementById("message").value)+'&message=Check%20this%20product%20on%20social.gogmat.com%20now.%0A'+encodeURI(document.getElementById("message").value)+'&redirect_uri='+encodeURI(document.getElementById("redirect").value); 

var aurl = encodeURI("https://www.facebook.com/dialog/feed?app_id=172099656214641&link="+document.getElementById("product").value+"&picture=http%3A%2F%2Fsocial.gogmat.com%2Fimages%2Flogo_03.jpg&name="+document.getElementById("subject").value+"&caption=Invitation%20to%20checkout%20product%20on%20Gogmat&description=Check%20this%20product%20on%20social.gogmat.com%20now.%0A"+document.getElementById("message").value+"&message=Check%20this%20product%20on%20social.gogmat.com%20now.%0A"+document.getElementById("message").value+"&redirect_uri="+document.getElementById("redirect").value); 
document.getElementById("link").value = aurl; 

//document.getElementById('button1').href='https://www.facebook.com/dialog/feed?app_id=172099656214641&link='+encodeURI(document.getElementById("product").value)+'&picture=http%3A%2F%2Fsocial.gogmat.com%2Fimages%2Flogo_03.jpg&name='+encodeURI(document.getElementById("subject").value)+'&caption=Invitation%20to%20checkout%20product%20on%20Gogmat&description=Check%20this%20product%20on%20social.gogmat.com%20now.%0A'+encodeURI(document.getElementById("message").value)+'&message=Check%20this%20product%20on%20social.gogmat.com%20now.%0A'+encodeURI(document.getElementById("message").value)+'&redirect_uri='+encodeURI(document.getElementById("redirect").value); 

} 
</script> 
</head> 
<body> 
<form action="#"> 
<input type="text" name="redirect" id="redirect" value="bleh" /> 
subject:<input type="text" id="subject" name="subject" value="" onkeyup="return blz()" /><br/> 
personal message:<input type="text" id="message" name="message" value="" onkeyup="return blz()" /><br/> 
select product for recommend:<input type="text" id="product" name="product" value="" onkeyup="return blz()" /><br/> 
link return:<input type="text" id="return" name="return" value="" onkeyup="return blz()" /><br/> 
<textarea id="link" name="link" rows="10" cols="40" readonly></textarea><br/> 
<a id="button1" href="" target="_blank"><img src="http://social.gogmat.com/components/com_referal/assets/images/bg_send.gif" alt="send button" /></a><br/> 
<input type="submit" /> 
</form> 
</body> 
</html> 

另一種解決方案是從字符串中刪除document.getElementById("redirect").value

+0

謝謝,幫助我。 – user1026137

+0

他確實有一個'