###取当前URL中的页面名称
window.location.href.split('/').pop().split('#')[0];
1. 56.com网站 | |
url类型: | |
http://www.56.com/w54/album-aid-7657069.html | |
http://www.56.com/w88/album-aid-7609666.html | |
http://www.56.com/u82/v_NTczMjc3NTk.html | |
http://www.56.com/w43/play_album-aid-7705385_vid-NDYwNjA4MTg.html | |
http://player.56.com/v_54644709.swf | |
对应的json请求: |
在IE8和Chrome下, 都有insertAdjacentElement这个方法, 但是FF中不支持。 | |
var newElem = document.createElement("span"); | |
newElem.innerHTML = 'this is a new element here'; | |
existingElement.insertAdjacentElement("AfterEnd", newElem); | |
实现方式有2种: | |
1. 用其他方法代替(经测试, 下述代码兼容IE7,8/FF/Chrome/Safari) | |
if(existingElement.nextSibling) | |
{newElem.parentNode.insertBefore(newElem, existingElement.nextSibling);} |
大部分的字符串替换都是用正则的, 如果需要类似C#的replace那样的功能, 直接用sub(). | |
"foo,bar,baz".sub("foo","boo") | |
=> "boo,bar,baz" |
只有 IE 和 Opera 的 HTMLDOMNode 有 removeNode 方法,其他浏览器则不支持。 | |
解决方法: | |
if(window.Node&&!window.opera){ | |
Node.prototype.removeNode=function(removeChildren){ | |
if(removeChildren||!this.hasChildNodes()){ | |
return this.parentNode.removeChild(this); | |
} | |
var $parent=this.parentNode; |
using System.Drawing; | |
using System.Drawing.Drawing2D; | |
public void ResizeStream(int imageSize, Stream filePath, string outputPath) | |
{ | |
var image = Image.FromStream(filePath); | |
int thumbnailSize = imageSize; | |
int newWidth, newHeight; |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>利用haslayout</title> | |
<style type="text/css"> | |
#left | |
{float:left;width:100px;height:100px;background-color:#ccc;border:2px solid #333; | |
} | |
#right | |
{overflow:hidden;zoom:1; border:2px solid #333;background:#ccc url(http://www.baidu.com/img/baidu_logo.gif) no-repeat; |
<h1>{{ page.title }} {% if page.tagline %} <small>{{ page.tagline }}</small>{% endif %}</h1> |
<h1>{{ page.title }} <small>{{ page.tagline }}</small></h1> |
###取当前URL中的页面名称
window.location.href.split('/').pop().split('#')[0];
在查看源码的页面, 执行
JSON.parse($('.webkit-line-content').innerHTML);
或者在普通tab页面, 执行
var result = JSON.parse($('body>pre').innerHTML);