Java 在SWT浏览器中运行JQuery脚本
我正在开发一个带有嵌入式SWT浏览器的Java应用程序。我想在SWT浏览器上运行jquery脚本。我已将jquery库文件放置在项目的src文件夹中。下面是程序Java 在SWT浏览器中运行JQuery脚本,java,jquery,eclipse,browser,swt,Java,Jquery,Eclipse,Browser,Swt,我正在开发一个带有嵌入式SWT浏览器的Java应用程序。我想在SWT浏览器上运行jquery脚本。我已将jquery库文件放置在项目的src文件夹中。下面是程序 import org.eclipse.swt.SWT; import org.eclipse.swt.browser.AuthenticationEvent; import org.eclipse.swt.browser.AuthenticationListener; import org.eclipse.swt.browser.Bro
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.AuthenticationEvent;
import org.eclipse.swt.browser.AuthenticationListener;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.ProgressEvent;
import org.eclipse.swt.browser.ProgressListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;
public class Dummy3 {
static int x=1;
public static void main(String args[])
{
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
//static int x=1;
final Browser browser = new Browser(shell, SWT.NONE);
final String s= "<html>"+
"<head>"+
"<title>The jQuery Example</title>"+
"<script type=\"text/javascript\""+
"src=\"jquery-2.1.1.min.js\"></script>"+
"<script type=\"text/javascript\" language=\"javascript\">"+
// <![CDATA[
"$(document).ready(function() {"+
"$(\"div\").click(function() {"+
"alert(\"Hello world!\");"+
"});"+
"});"+
// ]]>
"</script>"+
"</head>"+
"<body>"+
"<div id=\"newdiv\">"+
"Click on this to see a dialogue box."+
"</div>"+
"</body>"+
"</html>" ;
browser.setText(s);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
问题在于脚本无法定位lib>这里有一个解决方案 我刚刚通过将src改为
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
从W3Schools.com获取此链接,请尝试使用编辑器