请耐心等待,我对 Javascript 完全是个菜鸟:P。所以,我想做的是使用一个函数来加载网页。并且,在该功能完成后,我希望能够获取页面上某个元素的 HTML 代码。到目前为止,这是我的代码:
function change(){
window.location = "www.aWebPage.com"
window.onload = function() {
return document.ID_HERE.outerHTML;
}
}
Run Code Online (Sandbox Code Playgroud)
不管出于什么原因,HTML 代码的返回不起作用,但重定向却起作用。我是否正确地将值返回给函数?还有另一种方法可以使用仅在窗口重定向后执行的多个函数吗?
我的阵列:
NSMutableArray *squareLocations;
CGPoint dotOne = CGPointMake(1, 1);
[squareLocations addObject:[NSValue valueWithCGPoint:dotOne]];
CGPoint dotTwo = CGPointMake(10, 10);
[squareLocations addObject:[NSValue valueWithCGPoint:dotTwo]];
CGPoint dotThree = CGPointMake(100, 100);
[squareLocations addObject:[NSValue valueWithCGPoint:dotThree]];
int num = [squareLocations count];
for (int i = 0; i < num; i++)
{
NSValue *pointLocation = [squareLocations objectAtIndex:i];
NSLog(@"%@", pointLocation);
}
Run Code Online (Sandbox Code Playgroud)
当我要求squareLoctions对象计数时,它返回零?但就在上面要求计数我添加了三个NSValue对象??? 有人有主意吗?