我最近问了一个关于LocalStorage的问题.当项目尚未设置时,使用JSON.parse(localStorage.item)并且JSON.parse(localStorage['item'])无法返回NULL.
但是,JSON.parse(localStorage.getItem('item')确实有效.结果证明,JSON.parse(localStorage.testObject || null)也有效.
其中一条评论基本上是说localStorage.getItem()并且localStorage.setItem()应该始终是首选的:
getter和setter提供了一致的,标准化的和交叉浏览器兼容的方式来使用LS api,并且应该始终优先于其他方式.- 克里斯托弗
我喜欢使用localStorage的简写点和括号表示法,但我很想知道其他人对此的看法.localStorage.getItem('item')是否比localStorage.item或localStorage ['item'更好,或者只要它们工作的是速记符号好吗?
我的Phonegap Build应用程序中的所有内容都在运行,包括Analytics和FacebookConnect插件.但是,现在我想添加AdMob广告.
Phonegap Build不为AdMob提供内置插件,但根据Phonegap Build Plugins页面,您现在可以添加自己的自定义插件(请参阅页面底部的Contributing Plugins).
PhoneGap插件可以通过使用plugin.xml文件与PhoneGap Build兼容...
Phonegap Build Plugins页面引用GitHub上的Child Browser plugins.xml作为如何设置自定义plugin.xml的示例.以下是Child Browser plugin.xml的内容.
我不确定我需要修改此文件的哪些方面以及修改它们的内容.我想我已经为iOS和Android正确设置了Phonegap AdMob插件的文件结构(参见下面的文件结构),但我不确定如何在plugin.xml文件中正确引用这些文件.
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="com.phonegap.plugins.childbrowser"
version="3.0.4">
<name>Child Browser</name>
<asset src="www/childbrowser.js" target="childbrowser.js" />
<asset src="www/childbrowser" target="childbrowser" />
<!-- android -->
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<activity android:name="com.phonegap.plugins.childBrowser.ChildBrowser"
android:label="@string/app_name">
<intent-filter>
</intent-filter>
</activity>
</config-file>
<!-- Cordova 1.5 - 1.9 -->
<config-file target="res/xml/plugins.xml" parent="/plugins">
<plugin name="ChildBrowser"
value="com.phonegap.plugins.childBrowser.ChildBrowser"/>
</config-file>
<!-- Cordova 2.0.0 -->
<config-file target="res/xml/config.xml" …Run Code Online (Sandbox Code Playgroud) admob phonegap-plugins cordova phonegap-build phonegap-admob
我在<head>我的网络应用程序中有以下代码,但我只是在我的iPhone 3GS上获得白屏,而DOM加载而不是启动画面.
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<!--STYLES-->
<!--SCRIPTS-->
<!-- iPhone LAUNCHSCREEN-->
<link href="includes/images/apple-launch-480h.png" sizes="320x480" media="(device-height: 480px)" rel="apple-touch-startup-image">
<!-- iPhone (Retina) LAUNCHSCREEN-->
<link href="includes/images/apple-launch-480h2X.png" sizes="640x920" media="(device-height: 480px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image">
<!-- iPhone 5+ LAUNCHSCREEN-->
<link href="includes/images/apple-launch-568h.png" sizes="640x1136" media="(device-height: 568px)" rel="apple-touch-startup-image">
Run Code Online (Sandbox Code Playgroud)
如何让我的启动画面在所有版本的iPhone上正确显示?代码未显示,但我的网络应用程序图标在添加到主页时正在运行.我正在使用jQuery Mobile来构建这个Web应用程序.
我还确认PNG图像的大小正确,我删除了Web应用程序图标,刷新并重新添加到主屏幕多次.我在StackOverflow上找到的解决方案都没有为我工作.我没有尝试过JavaScript解决方案,因为我确信有一个纯CSS解决方案.
我想yes用一个movie1使用javascript 的键将值存储到localStorage中.但是,我希望1密钥的一部分基于movieID设置的任何内容是动态的.
这是我现在拥有的,但它不起作用:
movieID = 1;
localStorage.movie + movieID = 'yes';
Run Code Online (Sandbox Code Playgroud)
任何有关如何实现这一目标的想法或见解将不胜感激.谢谢!
我想创建一个preg_match函数来验证我的passowrds,但我不知道如何写它以允许使用以下特殊字符:!@#$%.
if(!preg_match(?????)$/', $password))
Run Code Online (Sandbox Code Playgroud)
这是我想要在正则表达式中使用的密码规则:
!@#$%感谢您提供的任何帮助.
我的手风琴使用data-toggle="collapse"和data-parent="#selector"使用Bootstrap 2.0.2很好,但是当我切换到2.0.3时,手风琴功能停止工作.
它仍然打开和关闭的目标 div,但它不会自动关闭打开的目标 div另一个时td与data-toggle="collapse"被点击.
你可以在这里看到它不能与2.0.3一起使用:http://chooserealtoday.com/#faq
以下代码示例也在JSFiddle上,网址为http://jsfiddle.net/N7MN9/3/.
<table id="faq-table" class="table table-bordered">
<tr>
<td class="question" data-toggle="collapse" data-target="#answer1" data-parent="#faq-table">
<p><strong>What is your name?</strong></p>
<div id="answer1" class="answer collapse">
<p>Mark Rummel</p>
</div>
</td>
</tr>
<tr>
<td class="question" data-toggle="collapse" data-target="#answer2" data-parent="#faq-table">
<p><strong>What is your favorite color?</strong></p>
<div id="answer2" class="answer collapse">
<p>Blue, no yellow.</p>
</div>
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
感谢您提供的任何帮助!
我对HTML和CSS非常熟悉,但对Javascript和jQuery不熟悉.我试图弄清楚如何在一个事件(.click)中发生多个jQuery效果.
我有一个有很多文本的DIV(.bio-description).我使.bio-description DIV高度仅为50px并将溢出设置为隐藏.当有人点击.bio-readmore DIV时,我希望发生以下情况:1).bio-description DIV的高度设置为'auto'(所以所有文本现在都可见),2).bio-readmore DIV消失,3).bio-readless DIV出现.
我在jQuery.com上阅读了很多内容,并在Google上进行了大量搜索.我可能已经遇到过这个问题,但是还没有理解如何实现它.
下面是我到目前为止的代码..bio-readmore在单击时会隐藏,但其他两个操作不会发生.除了.height之外,我还尝试过不同的效果,比如.css,.addClass和.animate.然而,没有任何作用,我认为它必须与我试图用一个事件处理多个效果的方式有关.
感谢您提供的任何帮助!
-标记
<script>
$(document).ready(function(){
$(".bio-readmore").click(function() {
$(".bio-description").height("auto");
}, function () {
$(".bio-readmore").hide();
}, function () {
$(".bio-readless").show();
});
});
</script>
<style type="text/css">
#wrapper {width:600px; margin:0 auto;}
.bio-description {background:#CCCCCC; padding:10px; height:50px; overflow:hidden;}
.bio-readmore {float:right; margin-right:40px; background:#66CC66; padding:3px;}
.bio-readless {display:none; float:right; margin-right:40px; background:#FF3333; padding:3px;}
</style>
</head>
<body>
<div id="wrapper">
<div class="bio-description">
<p>Morbi ut tincidunt magna. Ut justo eros, gravida a interdum eget, molestie eget nibh. Morbi sed mauris lectus, id tincidunt lectus. …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置$nextPageID并$nextPageTitle使用以下代码.不幸的是他们没有定.
$pageCategoryID = 1;
$nextPageOrder = 2;
$fetchedNextPageData = mysql_query("
SELECT pageID, pageCategoryID, 'order', title
FROM pages
WHERE pageCategoryID='$pageCategoryID' AND 'order'='$nextPageOrder'
") or die(mysql_error());
while ($nextPageArray = mysql_fetch_array($fetchedNextPageData)) {
$nextPageID = $nextPageArray['pageID'];
$nextPageTitle = $nextPageArray['title'];
}
Run Code Online (Sandbox Code Playgroud)
我的表pages包含一行,其中pageID = 2,pageCategoryID = 1,order = 2,title = Next Page,另外还有4个其他列,其中包含此查询不需要的数据.
此代码已经过简化以用于测试目的.我开始工作后会对它进行消毒处理.
有什么想法,我可以做些什么来使这些代码工作?
在mysql_query中将PHP中的文本和变量连接起来的正确方法是什么?这是我的尝试:
page.'$pageID'
Run Code Online (Sandbox Code Playgroud)
我希望它输出page3.
这是所有代码(简化为专注于mysql_query):
if ($_POST['pageProgress']) {
$pageProgress = $_POST['pageProgress'];
$pageID = 3;
$userID = 1;
$updateUserProgress = mysql_query("UPDATE test SET page.'$pageID'='$pageProgress' WHERE userID='$userID'") or die(mysql_error());
}
Run Code Online (Sandbox Code Playgroud)
如果我简单地替换page.'$pageID',所有代码都可以正常工作page3.
我正在尝试更改网页上 Twitter Bootstrap 选项卡的字体大小。看起来很简单,但由于某种原因它不起作用。
一切都在我的 JSfiddle 示例中工作:http : //jsfiddle.net/Ww5Cw/。
但是,它在实际网页上无法正常工作:http : //chooserealtoday.com/new.html(向下滚动一点 - 页面上只有标签)。
我已经通过 Google Chrome Inspector (.nav-tabs li a) 将字体大小更改为 22px 并且它可以工作,但是当我添加.nav-tabs li a {font-size:22px;}到我的styles.css. 我也试过了.nav-tabs > li > a。
关于为什么会这样的任何想法?谢谢!
我试图修改这个 jQuery 滑块解决方案:https : //stackoverflow.com/a/9864636/908491(使用第一个解决方案 - http://jsfiddle.net/sg3s/rs2QK/)。
这是我的 jsFiddle:http : //jsfiddle.net/markrummel/KHSSX/。
DIV 滑入工作正常,但滑出的跳出,而不是以与 DIV 滑入相同的速度平滑滑出。我已.hide()在 javascript 和overflow:hiddenCSS 中注释掉,以便我可以看到在哪里被滑出的 DIV 消失了。
这是我第一次使用.animate(),因此非常感谢您提供的任何帮助!
这是我的javascript:
$('.date-nav-prev').click(function () {
$('.date-nav-next').show();
var current = $('.visible-actions');
var prev = current.prev('.user-actions');
current.removeClass('visible-actions').animate({
left: current.width()
}, 500, function() {
//current.hide();
});
prev.addClass('visible-actions').show().css({
left: -(prev.width())
}).animate({
left: 0
}, 500);
});
$('.date-nav-next').click(function () {
var current = $('.visible-actions');
var next = current.next('.user-actions');
current.removeClass('visible-actions').animate({
left: -(current.width())
}, 500, function() …Run Code Online (Sandbox Code Playgroud)