最初,这篇文章是关于我尝试将ZeroClipboard注入网页并由我的Chrome扩展程序使用,但是我已经愚弄了这个场景,看似徒劳无益的尝试找出问题而我仍然无法做到这一点.让它工作.
我甚至难以在ZeroClipboard自己的GitHub上获得实际的,记录的"最小示例 "工作(诚然,我已经将源代码修改为实际上是HTML5有效的,但确切的原始版本也不起作用).即使test.html,包含在tar.gz存档中,也不起作用!
"最小例子":代码
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<input type="button" id="d_clip_button" data-clipboard-text="Copy Me!" value="Copy To Clipboard" />
<script src="ZeroClipboard.js"></script>
<script>
var clip = new ZeroClipboard( document.getElementById('d_clip_button') );
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
"最小示例":控制台输出
Uncaught TypeError: object is not a function index.html:11
Run Code Online (Sandbox Code Playgroud)
信息
zeroclipboard-1.0.7.tar.gz存档的全部内容与其位于同一目录中index.html.ZeroClipboard.js文件未损坏/不完整,正在正确加载.
要么我在这里遗漏了一些非常明显的东西,要么ZeroClipboard的文档/功能非常糟糕.
javascript google-chrome typeerror zeroclipboard referenceerror
我试图通过android Webview Activity调用javascript函数setGameName(),但它正在抛出uncaught ReferenceError:setGameName not defined at :1.
我的源代码如下:
webView2.setWebChromeClient(new WebChromeClient());
webView2.getSettings().setLightTouchEnabled(true);
webView2.getSettings().setJavaScriptEnabled(true);
webView2.addJavascriptInterface(jsInterface, "AndroidFunction");
webView2.loadUrl("file:///android_asset/www/index.html");
webView2.loadUrl("javascript:setGameName()");
Run Code Online (Sandbox Code Playgroud)
Html代码:
<body>
<script type="text/javascript">
function init() {
console.log("====== I am getting called::===");
var testVal = document.getElementById('playertextId').value;
AndroidFunction.proceedFurther(testVal);
};
function setGameName() {
console.log("====== Got the value===");
document.getElementById('gametextId').value;
};
</script>
</body>
Run Code Online (Sandbox Code Playgroud)
它正在加载index.html很好但在函数调用时抛出异常,请提供适当的解决方案..
更新:
i have found the problem the page is not getting loaded at the time of function call..(Since on giving a time delay of 5000ms it is getting called..)!!
Run Code Online (Sandbox Code Playgroud)
但是我如何实施呢?
是的,我知道这可能与航路点无关.对不起.
我遵循这个例子:http://imakewebthings.com/jquery-waypoints/#get-started
这是我非常简单的javascript:
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="/includes/js/waypoints/waypoints.min.js"></script>
<script type="text/javascript">
$(document).ready(function(direction) {
$('#example-basic').waypoint(function() {
notify('Basic example callback triggered.');
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
脚本已加载.jQuery代码几乎是从示例中逐字逐句复制的.
每当我滚动过去id为'example-basic'的元素时,我都会收到错误.
我找不到任何此类"通知"方法的信息.
有任何想法吗?
我是node.js的新手
我确实试过这个函数(foo.js)
module.exports.hello = function hello(name) {
console.log("hello " + name);
}
hello('jack');
Run Code Online (Sandbox Code Playgroud)
但我有这个错误
node foo.js
ReferenceError: hello is not defined
Run Code Online (Sandbox Code Playgroud) 我使用param下面的函数定义了我的可选参数,但是当我尝试Postman传递可选参数时,我得到了一个Reference Error 'off' is not defined.我无法弄清楚如何在下面的第二个函数中使用我传入的参数值,并且我假设我对它的错误使用是导致错误的原因.我试图在第一个函数中定义我的参数.
router.param('off', function(req, res, next, off){
req.offset = off;
next();
});
Run Code Online (Sandbox Code Playgroud)
我在这里用可选的param定义我的路线
router.get('/messages/:offset', function(request, res) {
ctxioClient.accounts(ID).messages().get({limit: 100, offset: off},
function ( err, response) {
)};
)};
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用AdMob广告在屏幕底部显示广告.
我在build.gradle文件中添加了以下行以获取AdMob sdk:
compile 'com.google.android.gms:play-services-ads:8.4.0'
Run Code Online (Sandbox Code Playgroud)
之后,我在XML中添加了AdView来展示广告:
<com.google.android.gms.ads.AdView
android:id="@+id/ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
app:adSize="BANNER"
android:layout_gravity="bottom"
app:adUnitId="@string/banner_ad_unit_id" />
Run Code Online (Sandbox Code Playgroud)
现在,我使用ad_view id制作AdView的参考资料,并使用以下代码行构建AdRequest来请求广告:
AdView mAdView = (AdView) findViewById(R.id.ad_view);
final AdRequest adRequest = new AdRequest.Builder()
// .addTestDevice("38C0F116926519A0CBAF1094898921FB")
.build();
if (mAdView != null)
mAdView.loadAd(adRequest);
Run Code Online (Sandbox Code Playgroud)
如果我取消注释addTestDevice功能但是当我尝试显示真实广告时,一切都很完美,我在logcat中收到以下错误:
12-23 17:18:02.234 13226-13226/com.abc.xyz I/Ads: Starting ad request.
12-23 17:18:02.234 13226-13226/com.abc.xyz I/Ads: Use AdRequest.Builder.addTestDevice("38C0F116926519A0CBAF1094898921FB") to get test ads on this device.
12-23 17:18:02.554 13226-13226/com.abc.xyz I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@42dd86b8 time:83516183
12-23 17:18:05.694 13226-13226/com.abc.xyz D/EgretLoader: EgretLoader(Context context)
12-23 17:18:05.694 13226-13226/com.abc.xyz D/EgretLoader: The …Run Code Online (Sandbox Code Playgroud) 我刚刚创建了一个新的 sveltekit 应用程序,安装了 flowbite 组件库和 flowbite-svelte-icons 并开始编写一些代码,但是当我检查我的应用程序时,localhost: 5173我看到的是以下消息:
ReferenceError: Request is not defined
at getRequest (file:///home/emmy/Documents/dev/public/water_watch/frontend/water_watch/node_modules/.pnpm/@sveltejs+kit@2.0.4_@sveltejs+vite-plugin-svelte@3.0.1_svelte@4.2.8_vite@5.0.10/node_modules/@sveltejs/kit/src/exports/node/index.js:101:2)
at file:///home/emmy/Documents/dev/public/water_watch/frontend/water_watch/node_modules/.pnpm/@sveltejs+kit@2.0.4_@sveltejs+vite-plugin-svelte@3.0.1_svelte@4.2.8_vite@5.0.10/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:475:27
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Run Code Online (Sandbox Code Playgroud)
真正奇怪的是,我什至在我的终端上看不到它,它只在浏览器上看到。
我不明白,所以我删除了我编写的所有代码,直到它只是创建项目时的默认内容,但我仍然收到相同的错误消息。
我试图通过使用onEndedHTML5中的属性一个接一个地播放3首歌曲.这是我的第一次尝试,但我收到了一个错误.
错误: Uncaught ReferenceError: src is not defined
nextSong marioKart.html:49
onended marioKart.html:58
以下是我的代码:
<script>
function nextSong(){
var song = document.getElementById("player");
song.attr(src,"countdown.wav");
}
</script>
</head>
<body>
<div style="position:relative">
<audio controls autoplay="true" onEnded="nextSong()" onplay="race()" >
<source id="player" src="startMusic.wav" type="audio/mpeg" />
</audio>
Run Code Online (Sandbox Code Playgroud)
有人可以帮我实现这个目标吗?
我一直在收到Uncaught ReferenceError: $ is not defined错误.我认为一切都很好并且正常工作.我的JQuery代码在我的Javascript文件中.我认为这不是它的工作原理吗?我应该有一个JQuery文件吗?
我把它放在我的HTML头脑中
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
这是我的Javascript文件:
function typing(id, sentence){
var result = $.Deferred();
var index=0;
var intObject= setInterval(function() {
document.getElementById(id).innerHTML+=sentence[index];
index++;
if(index==sentence.length){
clearInterval(intObject);
}
}, 100);
return result.promise();
}
var sleep = function(ms) {
var result = $.Deferred();
setTimeout(result.resolve, ms);
return result.promise();
};
typing('container','Subject Name:').then(function() {
return sleep(500);
}).then(function() {
return typing('container',' Carlos Miguel Fernando')
});
Run Code Online (Sandbox Code Playgroud)
我哪里做错了?
有没有办法让下面的代码工作?
(function(){
var n = "abc";
(new Function("return alert(n);"))();
})();
Run Code Online (Sandbox Code Playgroud)
如果我在浏览器中运行代码结果是:" 未捕获的ReferenceError:n未定义 ".
此外,我还需要一些其他变量,如"n",也可以在"新函数"中访问.
请帮忙,谢谢