Solved

getting document base using JSObject

Posted on 2001-06-06
3
453 Views
Last Modified: 2010-08-05
from my applet, I need to get the url of the html document using JSObject.
(I cannot use applet.getDocumentBase(), because it can be fooled with an html BASE tag).
for explorer I have a working solution, but in netscape, the following code does not work, href turns out to be null.


        JSObject window = getWindow(applet);
        JSObject location = (JSObject)window.getMember("location");
        Object href     = location.getMember("href");



0
Comment
Question by:omry_y
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
garyz31 earned 100 total points
Comment Utility
This works on Internet Explorer and Navigator:

Java class code:

import java.applet.Applet ;
import netscape.javascript.* ;
import java.awt.* ;
import java.lang.String ;


public class AppTest  extends java.applet.Applet
{
private String pageURL ;
public netscape.javascript.JSObject js ;

public void init()
{     try
     {
     JSObject js = netscape.javascript.JSObject.getWindow(this) ;
     pageURL = js.getMember("location").toString() ;
     }
     catch(netscape.javascript.JSException e)
     {     e.printStackTrace() ;     }
}
public void paint(Graphics g)
{     g.drawString(pageURL, 10, 10) ;
}
}//class end

----------------------------------------------

HTML code:

<HTML>
<HEAD>
</HEAD>f
<BODY>
<Applet code="AppTest.class" width=400 height=200 id=OBJECT1
MayScript     VIEWASTEXT>
</Applet>
</BODY>
</HTML>
-------------------------------------------------

Hope this helps.


0
 
LVL 4

Author Comment

by:omry_y
Comment Utility
sorry for the delay, I will check it shortly.
0
 
LVL 4

Author Comment

by:omry_y
Comment Utility
since I don't need the info anymore, I did not check it, but I assume that its okay.

thanks.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now