do external javascript on a website objective C

This is my first post so I am sorry for any mistakes I made :)

I know the title is confusing, but i will try to explain what I want.

I got this website, on the website there is a schedule, this schedule change when you change different values so that it consist with the appropriate person. When you change a value a JavaScript function is called. Is there any way for me to do this JavaScript (on a site I don't own) from objective-C.

So, what I want is this (in a very plain description):

do JavaScript call change() on website: "My website" (I know this is not valid, but this is what I want)

Also I would like to be able to change the different values and pass the function with parameters.

Thanks

Kristian

The website is here (Norwegian):

http://www.novasoftware.se/webviewer/(S(mfq2npum0th2lxb0g5oy3045))/design1.aspx?schoolid=60810&code=545354&type=3&id=1559)

Edit:

Hello I found another way to solve my problem.

The website is automatically generating an image for each of the students. The url of an image is similar to this link

(had some problems posting the URL)

Where you got &week=42 (you can change this to whatever you want and it works perfect). So I got it working for the MAC (in Safari 5).

But when I try to use this URL in the iPhone simulator I only get a white screen.

this is the code i use:

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.novasoftware.se/ImgGen/schedulegenerator.aspx?format=png&schoolid=60810/nb-no&type=3&id={76C567C0-161E-42C3-B054-8941DDD04F52}&period=&week=42&mode=0&printer=0&colors=32&head=0&clock=0&foot=0&day=0&width=1405&height=683&maxwidth=1405&maxheight=683"]]];

It works if I use a simpler URL like "http://www.google.com" :S Does the iPhone not support for aspx?

Upvotes: 0

Views: 189

Answers (1)

Mike Ruhlin
Mike Ruhlin

Reputation: 3556

I only know this in the context of iPhone APIs...

Assuming you have the page loaded in a UIWebView inside your app...

You can call UIWebView method stringByEvaluatingJavaScriptFromString: to send javascript to the page.

If the calling function returns anything, it will be typecast as a NSString and returned to your app, but in your case it looks like you can just ignore the return value. You might need to make your Javascript look something like:

(function(){
   change();
   return "hello world";
})();

because I'm not sure how well it handles void return values.

Upvotes: 1

Related Questions