LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 844|回复: 8

求助!帮忙!急急急急急急急急急急急急!!!

[复制链接]
发表于 2005-3-2 17:18:07 | 显示全部楼层 |阅读模式
有谁可以给我 看一下 ,往浏览器的 收藏夹里添加页面,小弟写 了 一个,但是一 重启就没有了 ,郁闷 !
我 的 真想知道这个代码该怎么写,我是用 JAVA写 的
在线等!急!!
发表于 2005-3-2 19:20:26 | 显示全部楼层
1. 用java写的??是java还是javascript?
2. 你在什么浏览器下测试的?是windows下面的还是linux下面?
回复 支持 反对

使用道具 举报

发表于 2005-3-2 19:48:29 | 显示全部楼层
如果是ie4以上在windows下面的话,在html中使用类似的代码应该没有问题:
<a href="javascript:window.external.AddFavorite('http://www.google.com','google搜索');">加入收藏夹</a>
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-3-3 03:27:03 | 显示全部楼层
用JAVA,在LINUX下
回复 支持 反对

使用道具 举报

发表于 2005-3-3 09:38:10 | 显示全部楼层
楼主用了什么api?jdk里面是没有的。我认为楼主多半是直接读firefox的配置文件?要不就是楼主java和javascript没有搞清楚 = =
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-3-3 16:30:40 | 显示全部楼层
没明白,我自己写一个浏览器,其他都差不多了,现在最大问题就是保存页面,每次一重起,收藏夹里的就没有,我的意思,把页面信息写入一个XML,从XML里面读出,我搞定了,就是写的问题,一重起,前面写的就没有了。我发下代码吧
import org.jdom.input.*;
import java.io.*;
import org.jdom.output.*;
import org.jdom.*;
import java.util.List;

public class XmlOperation {
//public static void main(String[] args) throws Exception {
// XmlOperation.PageWrite();
// XmlOperation.Read();
// XmlOperation.DirCreate();
//}
static Document doc =null;
static Element collection =null;
public static void PageWrite() throws Exception {
//boolean exists = fileExists.exists();
//if(!exists) {
if(doc==null&&collection==null){collection = new Element("Collection");
doc=new Document(collection);
}
//for(int i=0;;i++) {
String tree = IEInit.urlField.getText( );
Element page = new Element("age");
collection.addContent(page);
page.addContent(tree);
// FileWriter fw = new FileWriter(fileExists);

// out.output(doc,fw);
// fw.close();//q}
//}else {

}


public static void XMLWriter() throws Exception{
File fileExists = new File("Collection.xml");
FileWriter fw = new FileWriter(fileExists);
XMLOutputter out = new XMLOutputter();
Format format = Format.getCompactFormat();
XMLOutputter out = new XMLOutputter();
Format format = Format.getCompactFormat();
format.setEncoding("GB2312");
format.setIndent(" ");
out.setFormat(format);
out.output(doc,fw);
fw.close();
}

public static void Read() throws Exception {
SAXBuilder sax = new SAXBuilder();
Document doc = sax.build(new File("Collection.xml"));
Element collection = doc.getRootElement();
List list = collection.getChildren("age");
for(int i=0;i<list.size();i++) {

}
}

public static void DirCreate() throws Exception {

}
}
回复 支持 反对

使用道具 举报

发表于 2005-3-3 21:00:47 | 显示全部楼层
= =
原来是这样。你应该先把配置里面的domtree读进来,再添加。否则你就是覆盖操作了。原来的自然没有了。= =
回复 支持 反对

使用道具 举报

发表于 2005-3-3 23:48:56 | 显示全部楼层
为什么感觉描述一个问题像是挤牙膏一样,真是惜字如金亚。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-3-5 22:06:24 | 显示全部楼层
明白,了解,清楚,谢谢个位大哥
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表