我在html页面中有两个iframe
<table border="1" width="100%" height="100%">
<tr>
<th><iframe id="i1" width="100%" height="100%" src="/wordpress"></iframe></th>
<th><iframe id="i2" width="100%" height="100%" src="/wordpress"></iframe></th>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
我将点击事件发送到"a"标记以更改href,以便当点击该iframe中的任何链接并且id为"i1"的iframe的src更改后,第二个iframe的src也会随后更改,并且两个iframe都具有相同的页面视图.
$('a').click(function(e){
var id = $(this).attr('id');
var href = $(this).attr('href');
var ahash={
'id':id,
'href':href
};
if (getFrameElement().id=="i1")
window.parent.document.Aaddevent(e, ahash);
});
Run Code Online (Sandbox Code Playgroud)
由此改变了href
document.sendevent=function(e, ahash){
if (ahash.id!=undefined) {
$('#i2', window.parent.document).contents().find('#'+ahash.id).trigger(e);
} else {
$('#i2', window.parent.document).attr('src', ahash.href);
}
};
Run Code Online (Sandbox Code Playgroud)
这很好用.现在我的问题是我已经将id滚动事件发送到id为"i1"的iframe,这样当iframe滚动时,另一个iframe也会自动滚动.这在加载页面时运行良好,但是当触发click事件并且两个iframe的页面视图都更改时,滚动事件不起作用.
function getFrameTargetElement(oI)
{
var lF = oI.contentWindow;
if(window.pageYOffset==undefined)
{
lF= (lF.document.documentElement) ? lF.document.documentElement : lF=document.body;
}
//- return computed value
return lF;
}
//- get …Run Code Online (Sandbox Code Playgroud) 我试图使用jquery函数计算Android设备的方向更改窗口宽度$(window).outerWidth(true);.此计算为两者提供了正确的方向宽度iphone,ipad但在android中没有.如果我最初以横向模式或纵向模式加载页面我得到正确的宽度但是一旦我在加载页面后改变方向,我就像在横向模式中获得纵向模式的宽度,反之亦然.请建议发生了什么,以及如何处理此问题,以便在Android设备中获得方向更改时的正确窗口宽度
目前,我可以通过POST向http://sqlformat.org/api/v1/format API发出请求来以编程方式格式化我的 SQL 查询;但是这里提到的单个 IP 每小时可以提供 500 个请求的限制http://sqlformat.org/api/#usage。
我想知道是否有Javascript可用的本地或其他机制,通过它我可以在不访问网络的情况下在本地获得与从 SQLFormat.org 网站获得的结果相同的结果?
我在MySQL中有以下表格列.
id
user_primary_email
user_secondary_email
Run Code Online (Sandbox Code Playgroud)
我希望通过使用我可以实现的列user_primary_email和user_secondary_email唯一的组合UNIQUE KEY unique_key_name (user_primary_email, user_secondary_email)
上面添加的唯一键约束将帮助我实现以下场景,或者仅通过向单个列本身添加唯一键.
user_primary_email = 'xyz@gmail.com' AND user_secondary_email = 'pqr@gmail.com'
user_primary_email = 'xyz@gmail.com' AND user_secondary_email = 'pqr@gmail.com' //This will not be allowed to enter due to unique key constraint
Run Code Online (Sandbox Code Playgroud)
现在我遇到的问题是不应该允许以相反的方式添加相同的组合,如下所述.
user_primary_email = 'pqr@gmail.com' AND user_secondary_email = 'xyz@gmail.com' //This should not be allowed to add since already same email id combination added once
id | user_primary_email | user_secondary_email
-------------------------------------------------------
1 | xyz@gmail.com | pqr@gmail.com
-------------------------------------------------------
2 | pqr@gmail.com | …Run Code Online (Sandbox Code Playgroud) 我想格式化数字.我已经看到了一些在数字字符串中插入逗号的正则表达式表达式示例.所有这些都连续检查3位数,然后在数字中插入逗号.但我想要这样的东西:
122 as 122
1234 as 1,234
12345 as 12,345
1723456 as 17,23,456
7123456789.56742 as 7,12,34,56,789.56742
Run Code Online (Sandbox Code Playgroud)
我是正则表达式的新手.请帮我如何显示如上所示的数字.我尝试过以下方法.这总是检查3位数,然后添加逗号.
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
Run Code Online (Sandbox Code Playgroud)
但我想要逗号每两位数除了小数点前的最后3位数,如上所示.
我在我的windows系统中安装了xampp,并在我的linux系统中安装了lampp.我想使用java在"http:// localhost /"位置创建文件夹.我做了以下事情:
dirName = new File("http://localhost/"+name);
if(!dirName.exists()) {
dirName.mkdir();
}
Run Code Online (Sandbox Code Playgroud)
有可能吗?我的想法是以编程方式将一些文件下载到该位置.下载正在运行,但我如何创建文件夹,以便我可以通过它访问它http://example.com/name.这是跟踪用户相关内容所必需的.我可以访问已经安装了lampp的apache web服务器.如何创建文件夹并将下载保存到该文件夹,并以编程方式为文件夹及其中的内容分配权限,以便可以使用wget方法从那里下载保存的内容.
我有js文件,我需要调用php文件中定义的函数来计算值,然后继续下一步.这可能吗?我无法从我的脚本访问php文件的功能.还有一些方法可以在不改变扩展名的情况下将PHP文件包含在html页面中.html
我想solr 4.0使用java添加数据。我有以下数组List<Map<String, Object>> docs = new ArrayList<>();。我正在使用GSON方法将数组转换为 json 对象。我想将此数据提交给 solr。我怎么做?我已经阅读了solrj但不知道如何让它工作。
我现在正在使用cake php.我有两个文件example1.ctp和example2.ctp.我想在example1.ctp中包含example2.ctp,就像我们使用"include"添加php页面一样.我是新手,请建议我怎么做.
我已经完成了以下代码结构,addClass item_box_popup并且removeClass item_box点击了item_box div.
<div class="item_box"> <!--This is the small div which when clicked changes to the item_box_popup div-->
<div class="name">...</div>
<div class="detail">...</div>
</div>
<div class="item_box_popup"> <!--This div expands to show the detail and the children in it has a click event-->
<div class="name">...</div>
<div class="detail">...</div>
</div>
Run Code Online (Sandbox Code Playgroud)
其中item_box div有一个click事件,而不是孩子.工作是要改变到div item_box_pop div通过addClass和removeClass点击时.
在item_box_popup没有click事件,但孩子已定义click事件.我们已经习惯delegate定义click事件.item_box_popup .name等.
问题是当我们点击item_box div定义的click事件时.item_box_popup .name也会被触发.这可能是由于click for上定义的更改类所致 …
我有以下数组
var a = ["Banana/hgd/kjjkds", "Orange/kldj/kdl",
"Apple/jlds/ldks", "Mango/dsfj/dskj"]
Run Code Online (Sandbox Code Playgroud)
现在我想重新创建它,如下所示并输出
{
"a1" : "Banana",
"a2" : "hgd",
"a3" : "kjjkds"
}
{
"a1" : "Orange",
"a2" : "kldj",
"a3" : "kdl"
}
{
"a1" : "Apple",
"a2" : "jlds",
"a3" : "ldks"
}
{
"a1" : "Mango",
"a2" : "dsfj",
"a3" : "dskj"
}
Run Code Online (Sandbox Code Playgroud)
我尝试了以下方法但没有任何成功:
var b = [];
for (var i = 0; i< a.length; i++) {
b['a1'] = a[i].split("/")[0];
b['a2'] = a[i].split("/")[1];
b['a3'] = a[i].split("/")[2];
console.log(b);
b.push(b);
}
Run Code Online (Sandbox Code Playgroud)
在 …
我面临着一个新问题。我有以下用例。
var a = parseFloat(10); // Returns 10
var b = parseFloat(1.62); // Returns 1.62
var c = a + b; // Returns 11.620000000000001
Run Code Online (Sandbox Code Playgroud)
我想要c返回11.62。这里有什么问题?