I'm trying to change IE homepage with modifying registry. I've done this succesfully with a bat file;
REG ADD "HKCU\SOFTWARE\MICROSOFT\INTERNET EXPLORER\MAIN" /V "START PAGE" /D "http://www.stackoverflow.com/" /F
I also want to do this on java, tried this but it doesn't work.
import java.util.*;
import java.applet.Applet;
import java.awt.*;
class test {
public static void main(String args[]) {
try {
Runtime.getRuntime().exec("REG ADD 'HKCU\\Software\\Microsoft\\Internet Explorer\\Main' /V 'Start Page' /D 'http://www.stackoverflow.com/' /F");
} catch (Exception e) {
System.out.println("Error ocured!");
}
}
}
How can I get this working?
试试这个:
CMD /C REG ADD "HKCU\SOFTWARE\MICROSOFT\INTERNET EXPLORER\MAIN" /V "START PAGE" /D "http://www.stackoverflow.com/" /F
It's not via the registry, but it does the job. You can use this code (with Firefox compatibility too):
function setHome() {
if (document.all) {
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage('http://url_of_page.com');
} else if (window.sidebar) {
if(window.netscape) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
}
catch(e) {
alert("this action was aviod by your browser,if you want to enable,please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");
}
}
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage','http://url_of_page.com');
}
}
Then execute the function with:
<a href="javascript:setHome();">make your home page</a>
Source: HERE
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.