Webgadget and print (javascript) doesnt work?

Mac OSX specific forum
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Webgadget and print (javascript) doesnt work?

Post by jesperbrannmark »

Hi all.
I know several of you are using webgadget for printout in Windows. I am porting my program to Mac and got a unpleasant surprise.
There must be a workaround? Please.... ?

Code: Select all

If OpenWindow(0, 0, 0, 200,200, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)  
  WebGadget(0,0,0,150,150,"http://85.224.159.151/printtest.html")
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
The code of the html file is:
<html><body>PRINT TEST<br><a href=javascript:window.print()>Click here to print</a><hr></body></html>

I found something here http://macdevcenter.com/pub/a/mac/2004/ ... ebkit.html but dont know how to use it.

Jesper
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: Webgadget and print (javascript) doesnt work?

Post by jesperbrannmark »

My own solution to my own problem (with help from the Applescript wrapper talked about earlier here - great stuff):

COCOA_AppleScript("tell application "+Chr(34)+"Safari"+Chr(34)+Chr(13)+Chr(10)+"activate"+Chr(13)+Chr(10)+"end tell")
COCOA_AppleScript("tell application "+Chr(34)+"Safari"+Chr(34)+Chr(13)+Chr(10)+"make new document at end of documents"+Chr(13)+Chr(10)+"set url of document 1 to "+Chr(34)+url.s+Chr(34)+Chr(13)+Chr(10)+"end tell")
Post Reply