从xcode中的网页解析javascript window.close()函数

从xcode中的网页解析javascript window.close()函数,javascript,html,objective-c,xcode,Javascript,Html,Objective C,Xcode,我正在为我父母的照相馆业务写一份申请书 他们将所有活动图片上传到自己账户上的不同Flickr Photoset,在网站上他们有一个相册页面,上面有他们所有活动的集合,因此活动中的人们可以去看他们所有的照片条,以及每个单独的图片,然后自己下载 他们的大部分流量来自移动设备(我哥哥专门为移动设备屏幕和普通电脑屏幕设计了网站);不过,通过应用程序下载和共享图像更容易(多亏了苹果的iOS 6 UIActivityViewController和UICollectionView) 因此,我正在编写一个应用程

我正在为我父母的照相馆业务写一份申请书

他们将所有活动图片上传到自己账户上的不同Flickr Photoset,在网站上他们有一个相册页面,上面有他们所有活动的集合,因此活动中的人们可以去看他们所有的照片条,以及每个单独的图片,然后自己下载

他们的大部分流量来自移动设备(我哥哥专门为移动设备屏幕和普通电脑屏幕设计了网站);不过,通过应用程序下载和共享图像更容易(多亏了苹果的iOS 6 UIActivityViewController和UICollectionView)

因此,我正在编写一个应用程序,使查看和共享图片变得更容易。我已经完成了大部分工作,工作得很好!但是,它目前只支持iOS 6,我正在尝试包括iOS 5。它只支持iOS 6,因为我使用UICollectionView来显示事件中的图片。但是,由于iOS5不包含收藏视图,我使用相册网页的web视图来显示所有图像

选择图像时,可以选择要查看的图像大小。选择尺寸时,将打开一个新选项卡,其中包括图像和两个链接。一个用于下载图像,另一个用于关闭选项卡。这两个链接位于无序列表中,每个链接都是自己的列表项

这是下载图像的链接:

<a href="/downloadImage.php?link=IMG_LINK&amp;title=TITLE">Download Image</a>
当点击链接时,它会执行这些功能…对吗? 但这些都不起作用。我不知道如何让它们工作。

我正在寻找正确的方法来使用这个方法,或者一些替代方法,如果可能的话,使用Objective-C来做html通常做的事情。

我找到了一种基本上做我想做的事情的方法。而不是让webView在您选择图像大小时打开新页面。我使用以下代码将大小链接设置为仅下载图像:


// for links thats contain the displayImage.php do not allow user interaction
if ([[[request URL] absoluteString] hasPrefix:@"http://www.remembermephotobooths.com/displayImage.php?link="]) {
        //scan through the link url get the image link so that I can download it
        NSMutableArray *substring = [NSMutableArray new];
        NSScanner *scanner = [NSScanner scannerWithString:[[request URL] absoluteString]];
        [scanner scanUpToString:@"http://farm9" intoString:nil]; // Scan all characters after and including http://farm9 because all download links begin with http://farm9
        while(![scanner isAtEnd]) {
            NSString *string = nil;
            [scanner scanString:@"&title=" intoString:nil]; // Scan up to &title
            if([scanner scanUpToString:@"&" intoString:&string]) {
                [substring addObject:string];
            }
            [scanner scanUpToString:@".jpg" intoString:nil]; // Scan all characters up to and including .jpg because all images are jpegs
        }
        // save image to photo library
        UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:substring[0]]]], nil, nil, nil);
        // let the user know the image was saved
        MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        [hud setMode:MBProgressHUDModeText];
        hud.labelText = @"Saved Image!";
        [hud setMinShowTime:1.5];
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        [substring release];
        return NO; //this is what disables the links usual code and has it run my code instead
    }
    else { //all other links are enabled
        return YES;
    }

小贴士:不要写一堵水泥墙,以免让可能回答你问题的人泄气:)哈哈,谢谢……我觉得提供一些背景资料会很有用。看起来我想得太多了,我个人更喜欢背景而不是一堆问题;这表明了我的努力:)我认为提供背景也有助于找到替代方案。以防我疯了,我想做的事做不到。人们现在知道我想要什么,也可以为其他方式提供建议。
if ([[[request URL] absoluteString] hasPrefix:@"/downloadImage.php"]) {
    UIImageWriteToSavedPhotosAlbum(imageToBeSaved, nil, nil, nil);
    return NO;
} else if ([[[request URL] absoluteString] hasPrefix:@"javascript"]) {
    [webView goBack];
    return NO;
} else { return YES; }

// for links thats contain the displayImage.php do not allow user interaction
if ([[[request URL] absoluteString] hasPrefix:@"http://www.remembermephotobooths.com/displayImage.php?link="]) {
        //scan through the link url get the image link so that I can download it
        NSMutableArray *substring = [NSMutableArray new];
        NSScanner *scanner = [NSScanner scannerWithString:[[request URL] absoluteString]];
        [scanner scanUpToString:@"http://farm9" intoString:nil]; // Scan all characters after and including http://farm9 because all download links begin with http://farm9
        while(![scanner isAtEnd]) {
            NSString *string = nil;
            [scanner scanString:@"&title=" intoString:nil]; // Scan up to &title
            if([scanner scanUpToString:@"&" intoString:&string]) {
                [substring addObject:string];
            }
            [scanner scanUpToString:@".jpg" intoString:nil]; // Scan all characters up to and including .jpg because all images are jpegs
        }
        // save image to photo library
        UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:substring[0]]]], nil, nil, nil);
        // let the user know the image was saved
        MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        [hud setMode:MBProgressHUDModeText];
        hud.labelText = @"Saved Image!";
        [hud setMinShowTime:1.5];
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        [substring release];
        return NO; //this is what disables the links usual code and has it run my code instead
    }
    else { //all other links are enabled
        return YES;
    }