2013-10-23 26 views
0

我有一個電話差距/科爾多瓦應用程序。我有一個鏈接,2個文本框和文本的視圖。禁用從WebView的輸入字段中複製和粘貼基於ios應用程序的電話差距/ cordova。

我想從Web視圖中刪除複製,粘貼和選擇選項。

使用:

[webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none';"]; 

[webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitUserSelect='none';"]; 

我能夠從Web視圖禁用複製粘貼和選擇菜單,但它仍然在輸入字段,即文本框不散。

我試過的是禁用長按webview,禁用放大鏡,因此禁用複製和粘貼菜單,但菜單發生時,我們也在文本字段上雙擊。我如何禁用長按和雙擊在web視圖上?

我有點困惑,如果我禁用放大鏡,我的應用程序是否會清除應用程序商店的審查過程。

請幫我解決這個問題。

回答

1

我認爲這已在其他地方討論過,但最終爲我工作的是將以下內容添加到CSS。

/****************** 
disable select touch and hold and highlight colors 
******************/ 
html { 
    -webkit-user-select: none; 
    -webkit-touch-callout: none; 
    -webkit-tap-highlight-color:rgba(0,0,0,0); 
} 

如果你還希望它的輸入工作,然後 我加入

input { 
    -webkit-user-select: auto !important; 
    -webkit-touch-callout: default !important; 
} 

由於Phonegap styles -webkit-user-select: none; disabling text field

+0

感謝獅子座......這個工作,但沒有任何輸入區域。這隻適用於鏈接或文本。當我點擊並按住輸入區域時,我仍然可以看到複製和粘貼菜單。 – user2903299

+0

嗯我認爲我有相反的問題,不得不把它添加回輸入讓我檢查 – Leo

+0

你是對的我得到了同樣的行爲。對不起,這就是我得到的。除了通過使用文本和偵聽按鍵創建自己的文本框。 – Leo

0
Use this. 
<style type="text/css"> 
*:not(input):not(textarea) { 
    -webkit-user-select: none; /* disable selection/Copy of UIWebView */ 
    -webkit-touch-callout: none; /* disable the IOS popup when long-press on a link */ 
    }  
</style> 
If you want Disable only anchor button tag use this. 

a {-webkit-user-select: none; /* disable selection/Copy of UIWebView */ 
    -webkit-touch-callout: none; /* disable the IOS popup when long-press on a link */ 
} 
0

我不知道爲什麼要刪除複製&粘貼功能:安全問題?如果你想保持文本的選擇和你的應用程序中複製粘貼&但你想防止有人複製粘貼&您的內容與其他應用程序,然後檢查了科爾多瓦插件cordova-disable-copy-paste

+1

這可能會回答這個問題,但不鼓勵鏈接回答。鏈接往往打破;然後這樣的答案變成(幾乎)無用的。 – GhostCat

相關問題