我的一个朋友说使用<div style=""></div>而不是压缩的css文件放在link hrefhead部分给了一些性能提升.真的吗?
考虑使用船舶在蓝色div上方移动的CSS3动画.由于某种原因,船没有移动.HTML如下:
<div id="wrapper">
<div id="sea">
<img src="ship.png" alt="ship" width="128" height="128"/>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
为了制作CSS3动画,我使用以下内容:
#wrapper { position:relative;top:50px;width:700px;height:320px;
margin:0 auto;background:white;border-radius:10px;}
#sea { position:relative;background:#2875DE;width:700px;height:170px;
border-radius:10px;top:190px; }
#sea img {
position:relative;left:480px;top:-20px;
animation:myship 10s;
-moz-animation:myship 10s; /* Firefox */
-webkit-animation:myship 10s; /* Safari and Chrome */
@keyframes myship {
from {left: 480px;}
to{left:20px;}
}
@-moz-keyframes myship {
from {left: 480px;}
to {left:20px;}
}
@-webkit-keyframes myship {
from {left: 480px;}
to{left:20px;}
}
}
Run Code Online (Sandbox Code Playgroud)
船舶图像没有移动.任何帮助是极大的赞赏.
为了保护我正在处理的网站的管理员区域,我创建了一个包含的index.php
if (isset($_POST['password']) && isset($_POST['userName'])) {
if($_POST['password']==$pass && $_POST['userName']==$username)
{
header( 'Location: admin.php' ) ;
}
Run Code Online (Sandbox Code Playgroud)
这会重定向到名为admin.php的同一文件夹中的文件.问题是如果我写的话我可以访问这个文件localhost/folder/admin.php.请告诉我如何限制直接访问此页面.访问它的唯一方法应该是在用户名和密码之后的index.php.
考虑以下包含一些javascript利用prompt和的HTML片段unload.该prompt()方法工作正常但我想在重新加载或离开页面时提醒诸如Goodbye,用户之类的东西.任何帮助是极大的赞赏.
<body onload="promptName()" >
<script type="text/javascript">
function promptName()
{
var userName = prompt("What's your name ?", "")
return userName;
}
function goodBye()
{
alert("Goodbye, " + promptName() + "!");
}
window.onunload = goodBye();
</script>
</body>
Run Code Online (Sandbox Code Playgroud) 请考虑以下脚本来输出一些XML代码:
var xmlAsString = '<?xml version="1.0"?><person><name gender="male"></name></person>';
$(document).ready(function(){
$(".generator").click(function(){
alert(xmlAsString);
$("#container").append("<div id='contXML'>"+xmlAsString+"</div>")
});
});
Run Code Online (Sandbox Code Playgroud)
警报输出我想要的所有内容,但以后没有任何内容.如果我放一些随机字符串变量(没有<>字符一切正常).
请考虑以下有关Twitter API的代码段.data.followers_count如果置于锚标签中则无效.由于括号很多,我无法解决一些简单的连接问题.任何帮助是极大的赞赏.
function(data){
$('#twitter').html( document.getElementById('twitter').innerHTML + twitterusername[i] + ' ' +
<a href='someURL' title='someTitle'>data.followers_count</a> + ' Followers' + '<br/>');
}
Run Code Online (Sandbox Code Playgroud) 我有以下 HTML:
<a href="#">img/a.jpg</a>
<a href="#">img/b.jpg</a>
<a href="#">img/c.jpg</a>
Run Code Online (Sandbox Code Playgroud)
对于选定的链接,我有以下内容:
$(function() {
$("a").click( function( )
{
var current = $(this);
var name = current.attr('href');
current.addClass("selected");
var prev = current.closest("a").find("a.selected");
prev.removeClass("selected");
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
问题是,在我单击某个链接后,我单击的前一个链接不会取消选择(删除选择的类)。任何帮助将不胜感激。
以下代码适用于Vimeo API:
function getTitle($id){
$title = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$id.php"));
$theTitle=$title[0]['title'];
echo $theTitle;
}
Run Code Online (Sandbox Code Playgroud)
如果对于Dailymotion,我使用:
$id2 = 'xks75n';
function dailyMotionTitle($id2){
$dm = unserialize(file_get_contents("http://www.dailymotion.com/embed/video/".$id2));
echo $dm[0]['title'];
}
Run Code Online (Sandbox Code Playgroud)
我在偏移0为1374字节时得到错误.我知道我可以使用embed.ly或JSON解析但我更喜欢PHP.任何有关修复Dailymotion PHP解析的帮助表示赞赏.
这段代码给出了给定数字的计算阶乘的每个步骤结果,但我只想要最终的.
#include <stdio.h>
long int factorial(int n) {
if (n <= 1)
return(1);
else
n = n * factorial(n - 1);
printf("%d\n", n);
return(n);
}
main() {
int n;
printf("Enter n: ");
scanf("%d", &n);
//function call
factorial(n);
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我有三个一维数组.任务是将存在于三个阵列中的每个阵列中的数字存储在第四个阵列中.这是我的解决方案,如你所见,是不正确的.如果可能的话,我也对更快的算法感兴趣,因为它是O(N3)难度.
#include <stdio.h>
main(){
int a[5]={1,3,6,7,8};
int b[5]={2,5,8,7,3};
int c[5]={4,7,1,3,6};
int i,j,k;
int n=0;
int d[5];
for(k=0; k<5; k++){
for(j=0; j<5; j++){
for(i=0; i<5; i++){
if(a[i]==b[j] && b[j]==c[k])
{d[n]=a[i];
n++;}
else
d[n]=0;
}}}
//Iterate over the new array
for(n=0;n<5;n++)
printf("%d\n",d[n]);
return 0;
}
Run Code Online (Sandbox Code Playgroud) 今天我读了一些关于将多个JS和CSS文件压缩到一个文章的文章,以降低带宽和HTTP请求.与php文件有类似的情况吗?是否更好的创建包含少量PHP文件(header.php,footer.php等)的母版页,以便拥有格式良好且可读的代码而不仅仅是一个大的index.php?
考虑以下用字符串填充数组的函数(问题):
global $questions;
function printQuestions($lines){
$count = 1;
foreach ($lines as $line_num => $line) {
if($line_num%3 == 1){
echo 'Question '.$count.':'.'<br/>'.'<input type="text" value="' . $line . '" class="tcs"/>'.'<br/>';
$count++;
$questions[] = $line;
}
}
}
Run Code Online (Sandbox Code Playgroud)
问题数组被定义为全局但在函数外部无法访问.位于页面底部的以下代码块不返回任何内容:
<?php
if(isset($_POST['Submit'])){
foreach($questions as $qs)
echo $qs;
}
?>
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用会话变量,但我对这个关于全局变量的特殊问题感兴趣.任何帮助是极大的赞赏.