在mmm.xxx.com qqq.xxx.com domian 都是xxx.com
求解决办法
function getLocationHref(sParam){
sParam = strim(sParam);
700行var ii = location.href.indexOf("#");
if (ii==-1)
{
if (sParam!="")
{
return location.href + "#" + sParam;
}
}else{if (strim(location.href.substring(ii))=="#"||sParam=="")
{
return location.href.substring(0,ii);
}else{
return location.href.substring(0,ii)+"#"+ sParam;
}}
}
求解决办法
function getLocationHref(sParam){
sParam = strim(sParam);
700行var ii = location.href.indexOf("#");
if (ii==-1)
{
if (sParam!="")
{
return location.href + "#" + sParam;
}
}else{if (strim(location.href.substring(ii))=="#"||sParam=="")
{
return location.href.substring(0,ii);
}else{
return location.href.substring(0,ii)+"#"+ sParam;
}}
}
不清楚 在请说下
不要以为js里加了html里就不用加了。这个想法是十分错误的。╔═══════════════════
单机游戏下载: http://7game.net.cn/
╚═══════════════════
使用document.domain 这个必须保证一级域名是一样的
就是说只有
news.163.com和sports.163.com之间设置才可以通信.
直接在页面使用HTTP请求好象IE7下不行,没试过.
不过服务器端感觉应该可以解决,你的服务器端语言是什么?
java
我先说下思路吧,用apache的httpClient包在服务器端模拟个HTTP请求发送到另一台服务器上,然后返回的结果在再自己的服务器中response出去,这样两个网站的内容都变成一个网站的了.JS就可以为所欲为了.因为本地机器比较烂,拿TOMCAT部署测试的
部署的目录结构
webapps
testPost
test.jsp
WEB-INF
web.xml
lib
commons-httpclient-3.1-rc1.jar
commons-codec-1.3.jar
classes
test
TestPost.class
Test.class
package test;import java.io.IOException;
import java.io.PrintWriter;import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;public class Test extends HttpServlet{
public void doGet(HttpServletRequest rq,HttpServletResponse rp) throws IOException{
rp.setContentType("text/html;charset=GBK");
String temp=TestPost.getGetResponseWithHttpClient("http://book.csdn.net/bookfiles/475","GBK");
PrintWriter out = rp.getWriter();
out.print(temp);
out.close();
}
}
package test;import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthPolicy;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.GetMethod;import test2.Test3;public class TestPost {
//获得ConnectionManager,设置相关参数
private static MultiThreadedHttpConnectionManager manager = new MultiThreadedHttpConnectionManager(); private static int connectionTimeOut = 20000; private static int socketTimeOut = 10000; private static int maxConnectionPerHost = 5; private static int maxTotalConnections = 40; // 标志初始化是否完成的flag
private static boolean initialed = false;
// 初始化ConnectionManger的方法
public static void SetPara() {
manager.getParams().setConnectionTimeout(connectionTimeOut);
manager.getParams().setSoTimeout(socketTimeOut);
manager.getParams().setDefaultMaxConnectionsPerHost(
maxConnectionPerHost);
manager.getParams().setMaxTotalConnections(maxTotalConnections);
initialed = true;
}
// 通过get方法获取网页内容
public static String getGetResponseWithHttpClient(String url, String encode) {
HttpClient client = new HttpClient(manager); if (initialed) {
Test3.SetPara();
} //代理的用户名和密码
List authPrefs = new ArrayList(2);
authPrefs.add(AuthPolicy.DIGEST);
authPrefs.add(AuthPolicy.BASIC);
client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY
,authPrefs);
UsernamePasswordCredentials creds = new UsernamePasswordCredentials("XXXXXX", "XXXXXX");
client.getState().setProxyCredentials(AuthScope.ANY, creds); HostConfiguration hcf =new HostConfiguration ();
hcf.setProxy("XXX.XXX.XXX.XXX",8080);
GetMethod get = new GetMethod(url);
get.setFollowRedirects(true); String result = null;
StringBuffer resultBuffer = new StringBuffer(); try { client.executeMethod(hcf,get); BufferedReader in = new BufferedReader(new InputStreamReader(get
.getResponseBodyAsStream(), get.getResponseCharSet())); String inputLine = null; while ((inputLine = in.readLine()) != null) {
resultBuffer.append(inputLine);
resultBuffer.append("\n");
} in.close(); result = resultBuffer.toString(); // iso-8859-1 is the default reading encode
result = TestPost.ConverterStringCode(resultBuffer
.toString(), get.getResponseCharSet(), encode);
} catch (Exception e) {
e.printStackTrace(); result = "";
} finally {
get.releaseConnection();
}
return result;
}
private static String ConverterStringCode(String source, String srcEncode,
String destEncode) {
if (source != null) {
try {
return new String(source.getBytes(srcEncode), destEncode);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return "";
}
} else {
return "";
}
}
}
是的。
CSDN的网摘已经提供了这个功能,可以自己输入标题
这样写对服务器有负作用吗?
楼主需要简化代码测试。
统一域下的frame互操作经过我刚才的测试,是绝对没有问题的。包括操作location.href设2个域名
a.tt.com
b.tt.com
t.php放a下,t2.php放b下
t.php<script language="javascript" type="text/javascript">
<!--
document.domain = "tt.com";
function abc()
{
alert( location.href );
alert( location.pathname );
//location.href = "http://b.tt.com/";
}
//-->
</script><iframe name="" width=420 height=330 frameborder=0 scrolling=auto src="http://b.tt.com/t2.php"></iframe>t2.php<script language="javascript" type="text/javascript">
<!--
document.domain = "tt.com";
//alert(window.parent.document.location.href);
parent.abc();
//-->
</script>
但是却执行到这里又去调用这个方法 出现权限不足。怎么直接刷新的?
所以的函数中所有if()语句 不管是false ,还是true都继续执行