0

I am using JavaScript application to run on android device . inside the JavaScript i have window.open(xx.txt) . I can open the file on the android device. but always the width and height is at maximum. In desktop it shows a "close" button. but when i run on android device (tablet) it doesn’t show the close button. I have to rely on the back key button. I specified height and width explicitly, but still no effect.

Let me know if am missing something here. I wish to know how we can use window.open function to open a file on android tablet/mobile. It need to show the close button for user to close the file and come back to the html page.

code snippet : html page :

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <meta name="viewport" content="target-densitydpi=device-dpi" />
    <meta name="viewport" content="width=device-width" />
    <meta name="viewport" content="initial-scale=1.0" />
    <meta name="viewport" content="minimum-scale=1.0" />
    <meta name="viewport" content="maximum-scale=1.0" />
    <meta name="viewport" content="user-scalable=0" />

on displaying the html page. it fecthes a log-error.txt (text file) from the local directory on android SD card.

inside my javascript page

  new_myText.innerHTML="Me: <a href='#' onclick=displayWindow('"+imagePath+"')>"+imagePath+"</a>";

function displayWindow(imagePath)
{
    alert(imagePath);
    var windowSize = "width= 100 ,height= 100 ,scrollbars='yes'";
    window.open(imagePath,'popup', windowSize); 
}
Sunil
  • 521
  • 1
  • 7
  • 24
  • I'm not sure whether you're complaining about Android not obeying the width and height information you provide, or not. Also, you need to let us know why the close button is not being displayed (outside of visible area maybe?Or maybe some incompatible JavaScript trying to add it dynamically?) and whether you're displaying a website (aka are in the browser app) or use a WebView. Etc pp. Please clarify. – class stacker Mar 25 '13 at 07:09
  • let me give you the answers: I am using android web view to open the html page. once open it fetches a file location on the sd card. i am implementing a function to open and read the file when user tap on the location link. i used window.open(url of the file, 200,200) it opens a file in a new window but the window is fully overlapped . even though i gave the width and height as 200, it takes the full length of the tablet. i tried to scroll up and down to find the close button, but i couldnt find the close button to close the file (window) and come back to my original html page. – Sunil Mar 25 '13 at 07:50
  • var windowSize = "width= 100 ,height= 100 ,scrollbar='yes'"; window.open(imagePath,'popup', windowSize); – Sunil Mar 25 '13 at 07:55
  • Thanks for the update. Can you update your question with a snippet of the relevant HTML part of the page you open (the part which is supposed to display the button)? Are you doing any Java Script on that page? Is the button maybe enabled by JavaScript? Etc. -- If you update, please leave a comment here which starts with "@ClassStacker", otherwise I won't get a notification. Thanks. – class stacker Mar 25 '13 at 08:12
  • @ClassStacker : I have updated the code ..there is nothing on the html page. inside my javascript file, i am handling onclick on the file url ..to initiate the window.open (). it opens the file..but it occupies the entire screen with no close button seen – Sunil Mar 25 '13 at 08:40
  • You mean you're simply displaying a _.txt_ file in a new browser window and want Android to provide an explicit _close_ button? Well, Android's _close_ button in this case is the _back_ button, which every Android user would intuitively use, hence I'd say you don't have any problem at all. Okay maybe somewhere in your non-Androidish spec a _close_ button is required but of course only because usually, there's no user level "close" button sucgh as on Android. Of course, you can add a close button if you convert your _.txt_ into `HTML` and add a close button. – class stacker Mar 25 '13 at 09:14
  • but here if android back key is to be used..then i may need to be careful how to handle the session right? when i click on the url and it opens the file..then i click on back key to come back to the application, then i need to ave the state right? – Sunil Mar 25 '13 at 10:23
  • You can open the file using `startActivityForResult()` to keep your original Activity alive while the user views the data, if you are concerned about "saving the state". However, you would want to "save the state" anyway if it's important enough. But that's a whole different story. – class stacker Mar 25 '13 at 10:45
  • @ClassStacker : here my confusion is...when i call window.open() from my javascript..it calls Android browser internally? – Sunil Mar 25 '13 at 11:45
  • Your question is really a duplicate of [this one here](http://stackoverflow.com/questions/7308904/link-should-be-open-in-same-web-view-in-android) but you should try to experiment with the return value of the `shouldOverrideUrlLoading()` method which the solution suggests if it does not work as intended. – class stacker Mar 25 '13 at 13:19

0 Answers0