这是我要做的(伪代码):
想象一下,示例中cookie的名称是"已访问",并且它不包含任何内容.
if visited exists
then alert("hello again");
else
create visited - should expire in 10 days;
alert("This is your first time!")
Run Code Online (Sandbox Code Playgroud)
我怎样才能在JavaScript中实现这一目标?
我确实只是复制并粘贴了来自YouTube开发者页面的iframe嵌入式YouTube播放器API参考代码(来自"使用入门"标题下方).唯一的区别是,当状态改变时我添加了一个警报,因为我认为我在onPlayerStateChange函数中做错了.
你可以在http://jsfiddle.net/jesMv/看到jsFiddle .
如上所述,它只是YouTube开发人员页面中添加的代码的精确副本
alert('State Changed')
Run Code Online (Sandbox Code Playgroud)
作为在onPlayerStateChange函数中触发的第一件事.
然而,没有任何事情发生......无论我如何看待这个以及我改变了什么,我都无法让onStateChange做任何事情.
我该如何解决这个问题?
假设我有一个excel表,每列有4列数据和20,000行数据.
获得它的最有效方法是什么,以便将所有数据合并到一列中(IE-A列80,000行数据,而不是跨4列分布的20,000行数据).
此外,如何实现该解决方案.我的意思是,如果您的解决方案不是"公式"而是VBA,我该如何实施该解决方案?
谢谢!
我正在尝试将发布到我的服务器的数据记录到文本文件中。发送到我的服务器的数据示例位于此处:
http://dev.datasift.com/docs/push/sample-output-file-based-connectors
那个页面上写着:
“对于所有基于文件的连接器,有效负载是一个包含元数据的 JSON 对象以及一个包含来自流的 JSON 对象的数组。”
我在 datasift 将数据发送到的位置有以下 PHP:
<?php
$myFile = "testFile.txt";
$phpObj = json_decode($_POST['json']);
file_put_contents($myFile,$phpObj);
echo '{ "success": true }';
?>
Run Code Online (Sandbox Code Playgroud)
我知道正在发送数据,但我的文本文件中没有记录任何内容。每次都是一片空白。不幸的是,我不知道从这里去哪里。有任何想法吗?
我想在PHP中发表如下声明:
if(preg_match("/apples/", $ref1, $matches)) OR if(preg_match("/oranges/", $ref1, $matches)) {
Then do something }
上面的每一个本身都可以正常工作,但我无法弄清楚如何使它如果其中任何一个为真,那么执行我在其下面的功能.
我需要使用javascript将iframe插入div中.我需要用javascript写的这个,所以我可以在greasemonkey脚本中使用代码(而greasemonkey只允许使用javascript).
greasemonkey脚本将AOL的搜索栏插入各种网站.我已经包含了下面的工作HTML代码,因此您可以测试它以查看最终结果是什么时候这样做.
这正是我需要做的,用HTML编写:
<div style="overflow: hidden; width: 564px; height: 43px; position: relative;">
<iframe src="http://aol.com" style="border: 0pt none ; left: -453px; top: -70px; position: absolute; width: 1440px; height: 775px;" scrolling="no"></iframe>
</div>
Run Code Online (Sandbox Code Playgroud)
我需要让这个HTML代码在greasemonkey中运行,这需要用javascript编写.这是我到目前为止所得到的(我的最后一个问题是"伪代码"):
var makeIframe = document.createElement("iframe");
makeIframe.setAttribute("src", "http://aol.com");
makeIframe.setAttribute("scrolling", "no");
makeIframe.setAttribute("border", "0pt");
makeIframe.setAttribute("border", "none");
makeIframe.setAttribute("left", "-453px");
makeIframe.setAttribute("top", "-70px");
makeIframe.setAttribute("position", "absolute");
makeIframe.setAttribute("width", "1440px");
makeIframe.setAttribute("height", "775px");
makeIframe.setAttribute("scrolling", "no");
var makediv = document.createElement("div");
makediv.setAttribute("height", "43px");
makediv.setAttribute("width", "564px");
makediv.setAttribute("position", "relative");
makediv.setAttribute("overflow", "hidden");
Run Code Online (Sandbox Code Playgroud)
我已经知道如何插入iframe或将div插入我需要插入的网站的源代码中,通过这样做:
var getRef = document.getElementById("div-id-to-insert-element-before");
var parentDiv = getRef.parentNode;
parentDiv.insertBefore(iframe OR div, getRef); …Run Code Online (Sandbox Code Playgroud) 如何使用javascript"点击"没有ID,值,类或名称的按钮?
该按钮的相关代码是:
<div class="classname anotherclassname" title="">
<div>
<button type="submit"><i class="anotherclass anotherclassname"></i>ImAButton</button>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我举一个例子来说明我目前的情况,因为我知道这只是stackoverflow上的礼仪,但我甚至不知道从哪里开始.我目前知道如何使用javascript单击按钮的唯一方法是使用:
document.getElementById("myButtonId").click();
Run Code Online (Sandbox Code Playgroud)
这不适用于此.
我有一个存储在 .txt 文件中的 URL 列表(我使用的是 Windows 7)。
URL 的格式是这样的:
somesite1.com
somesite2.com
somesite3.com
sub1.somesite3.com
sub2.somesite3.com
sub3.somesite3.com
sub1.somesite3.net
sub1.somesite1.org
Run Code Online (Sandbox Code Playgroud)
在notepad++中,有一个选项可以使用“用正则表达式查找替换”,并且我相当确定gvim允许用户使用正则表达式(尽管我不完全确定如何在Gvim中使用它们)。
无论如何,我不知道要在查找和替换框中放入什么,以便它可以遍历文件的内容并只留下根域。如果操作正确,上面的示例列表将变成这样:
somesite1.com
somesite2.com
somesite3.com
somesite3.com
somesite3.com
somesite3.com
somesite3.net
somesite1.org
Run Code Online (Sandbox Code Playgroud)
有人可以帮我吗?
我在Excel电子表格中有两列电子邮件地址.我需要知道列A中是否存在B列中的电子邮件地址.
如果列A中的电子邮件地址确实存在于列A中,我希望它读取列C中相应电子邮件地址旁边的"匹配找到".
我正在玩我在StackOverflow上找到的东西,它看起来像:
=IF(ISNA(VLOOKUP
Run Code Online (Sandbox Code Playgroud)
但我不能让它工作(我不是Excel的完全新手,但不幸的是,我不是很熟悉的更先进的公式)
我正在尝试使用 JavaScript 确定字符串的长度,如果该字符串大于 X 长度,则删除足够的字符以使其成为 X 长度。
下面是一个更具体的例子:
假设我想计算这个字符串的长度:
testing this
Run Code Online (Sandbox Code Playgroud)
我可以做这样的事情:
str="testing this";
len=str.length;
document.write(len);
Run Code Online (Sandbox Code Playgroud)
(这将返回 12 的长度)
现在,假设我只希望该字符串的长度为 4 个字符,并且我想从字符串的末尾修剪足够的字符,使其长度仅为 4 个字符(或 X 个字符)。
如果我知道怎么做,结果将是:
test
Run Code Online (Sandbox Code Playgroud)
有人愿意帮我吗?
javascript ×5
excel ×2
php ×2
cookies ×1
dom ×1
greasemonkey ×1
if-statement ×1
json ×1
notepad++ ×1
preg-match ×1
regex ×1
string ×1
vba ×1
vim ×1
youtube-api ×1