我想在每个youtube链接的末尾添加一些HTML,以便在litebox中打开播放器.到目前为止这是我的代码:
$(document).ready(function() {
var valid_url = new RegExp('youtube\.com\/.*v=([a-zA-Z0-9_-]+)');
var image_data = 'base64 encoded image';
init();
function init() {
$('a').each(function() {
if (valid_url.test($(this).attr('href'))) {
$(this).after( ' <img src="' + image_data + '" onclick="open_litebox(\'hi\');" />' );
}
});
}
function open_litebox(param) {
alert(param);
}
});
Run Code Online (Sandbox Code Playgroud)
它可以在youtube链接之后注入一些HTML,就像这样:
<img src="base 64 data" onclick="open_litebox('hi')">
Run Code Online (Sandbox Code Playgroud)
但是当我点击这个时,open_litebox()函数不会被调用.查看错误控制台我可以看到一个错误open_litebox is not defined,但我已经定义了它.
我对这里出了什么问题一无所知,有人可以帮我一把吗?
谢谢.
我通常会在XNA论坛上寻求帮助,但他们现在已经失败了,所以我来到这里.
我正在制作一个新的XNA游戏,我希望有一个玩家类.目前我有一个主要的游戏类叫Dots.这代表了主要游戏.这就是我Player班级目前的布局:
namespace Dots
{
class Player : Microsoft.Xna.Framework.Game
{
Texture2D PlayerTexture;
Vector2 PlayerPosition;
public Player()
{
Content.RootDirectory = "Content";
PlayerTexture = Content.Load<Texture2D>("Player");
PlayerPosition = Vector2.Zero;
}
public void Update()
{
}
public void Draw(SpriteBatch SpriteBatch)
{
}
}
}
Run Code Online (Sandbox Code Playgroud)
但我收到一个错误,我无法解决如何解决.错误是:
加载"播放器"时出错.找不到GraphicsDevice组件.
它把它扔在这条线上:PlayerTexture = Content.Load<Texture2D>("Player");.
我在主游戏课中看到有这一行:Graphics = new GraphicsDeviceManager(this);但我不知道如何处理它.我把它传给我的Player班级,还是什么?
任何帮助表示赞赏,谢谢.
我有一些JS代码将背景淡化成深色并打开一个白色模态窗口,如下所示:
function open_litebox(link) {
var overlay_black = 'position:absolute;top:0%;left:0%;width:100%;height:100%;background:black;z-index:1001;opacity:0.5;';
$('body').append('<div style="' + overlay_black + '"></div>');
var overlay_white = 'position:absolute;top:25%;left:25%;padding:5px;background-color:white;z-index:1002;overflow:auto;';
$('body').append('<div style="' + overlay_white + '"><p>heeeyyy</p></div>');
}
Run Code Online (Sandbox Code Playgroud)
但问题是,它并没有出现在屏幕中死角.我希望模态窗口在垂直和水平方向都位于死点,但我不知道模态窗口内的内容的宽度/高度是多少,所以我无法设置固定值.
欢迎任何帮助,欢呼.
这是我试图用来将POST数据发送到URL并带回其响应的方法:
public string sendPOST(string URL, string postData)
{
byte[] byteArray;
Stream webpageStream;
StreamReader webpageReader;
String webpageContent;
byteArray = Encoding.UTF8.GetBytes(postData);
_webRequest = WebRequest.Create(URL);
_webRequest.Method = "POST";
_webRequest.ContentType = "application/x-www-form-urlencoded";
_webRequest.ContentLength = byteArray.Length;
webpageStream = _webRequest.GetResponse().GetResponseStream();
webpageStream.Write(byteArray, 0, byteArray.Length);
webpageStream.Close();
webpageReader = new StreamReader(webpageStream);
webpageContent = webpageReader.ReadToEnd();
return webpageContent;
}
Run Code Online (Sandbox Code Playgroud)
我从MSDN网页上获得了很多这样的代码,所以我知道我大致走在正确的轨道上...但是当我使用以下方法调用该方法时:
string test = webHelper.sendPOST("http://google.com", "var=1");
MessageBox.Show(test);
Run Code Online (Sandbox Code Playgroud)
应用程序刚刚锁定.我调试了该方法,据我所知,代码运行良好,直到这一行:
webpageStream = _webRequest.GetResponse().GetResponseStream();
Run Code Online (Sandbox Code Playgroud)
我试过在try块中把它包起来但是根本没有抛出任何exeptions.
有没有人有足够的网络请求经验来帮助我?
非常感谢 :)
c# ×2
javascript ×2
jquery ×2
class ×1
css ×1
function ×1
html ×1
modal-dialog ×1
onclick ×1
post ×1
scope ×1
webrequest ×1
xna ×1