473,385 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

[beginer]Why this script failed to work?

HI:

I paste my script below:

<html>
<head>
<script src="http://code.activestate.com/js/jquery-1.2.1.js"
type="text/javascript"></script>

<script language="javascript" type="text/javascript">
function onLoad() {
var frame1 = $("#frame1");
alert("1");
var innerDoc = (frame1.get(0).contentDocument) ?
frame1.get(0).contentDocument : frame1.get(0).contentWindow.document;
alert("2");
var b=innerDoc.body;
alert("3");
alert(innerDoc.body.scrollHeight);
}
</script>

</head>
<body>
<iframe id="frame1" src="http://www.baidu.com" width=100%
onload="onLoad()">
</body>
</html>

The script only alert "1" in IE and alert "2" in firefox. It seems
stop execute after then.

Does any guy know why?
Sep 28 '08 #1
4 1668
On Sep 28, 5:14*pm, devdoer <devdo...@gmail.comwrote:
HI:

I paste my script below:

<html>
* * <head>
* * * * <script src="http://code.activestate.com/js/jquery-1.2.1.js"
type="text/javascript"></script>

* * * * <script language="javascript" type="text/javascript">
* * * * * * function onLoad() {
* * * * * * * * var frame1 = $("#frame1");
* * * * * * * * alert("1");
* * * * * * * * var innerDoc = (frame1.get(0).contentDocument) ?
frame1.get(0).contentDocument : frame1.get(0).contentWindow.document;
* * * * * * * * alert("2");
* * * * * * * * var b=innerDoc.body;
* * * * * * * * alert("3");
* * * * * * * * alert(innerDoc.body.scrollHeight);
* * * * * * }
* * * * </script>

* * </head>
* * <body>
* * * * <iframe *id="frame1" src="http://www.baidu.com" width=100%
onload="onLoad()">
* * * * </body>
* * </html>

The script only alert "1" in IE and alert "2" in firefox. It seems
stop execute after then.

Does any guy know why?
testtttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttt tttttttttttttttttttttttttttttttttttttttttttttttttt ttttttttt
Sep 28 '08 #2
devdoer wrote:
HI:

I paste my script below:

<html>
<head>
<script src="http://code.activestate.com/js/jquery-1.2.1.js"
type="text/javascript"></script>

<script language="javascript" type="text/javascript">
function onLoad() {
var frame1 = $("#frame1");
Why the # character in there? Maybe it's a prototype.js syntax thing, I
don't know.
alert("1");
var innerDoc = (frame1.get(0).contentDocument) ?
You're not checking first if frame1 != null, which it would be if that #
above was wrong. You're also trying to access the contentDocument of a
page in a different domain. This is actively blocked by the browsers for
security reasons.
frame1.get(0).contentDocument : frame1.get(0).contentWindow.document;
alert("2");
var b=innerDoc.body;
alert("3");
alert(innerDoc.body.scrollHeight);
}
</script>

</head>
<body>
<iframe id="frame1" src="http://www.baidu.com" width=100%
onload="onLoad()">
</body>
</html>

The script only alert "1" in IE and alert "2" in firefox. It seems
stop execute after then.

Does any guy know why?
Sep 28 '08 #3
On Sep 28, 6:07*pm, Stevo <n...@mail.invalidwrote:
devdoer wrote:
HI:
I paste my script below:
<html>
* * <head>
* * * * <script src="http://code.activestate.com/js/jquery-1.2.1.js"
type="text/javascript"></script>
* * * * <script language="javascript" type="text/javascript">
* * * * * * function onLoad() {
* * * * * * * * var frame1 = $("#frame1");

Why the # character in there? Maybe it's a prototype.js syntax thing, I
don't know.
* * * * * * * * alert("1");
* * * * * * * * var innerDoc = (frame1.get(0).contentDocument) ?

You're not checking first if frame1 != null, which it would be if that #
above was wrong. You're also trying to access the contentDocument of a
page in a different domain. This is actively blocked by the browsers for
security reasons.
But by using firebug, I can view the innerDoc 's content and other
attributes in the debug window.
Sep 28 '08 #4
On Sep 28, 7:14*pm, devdoer <devdo...@gmail.comwrote:
HI:

I paste my script below:

<html>
* * <head>
* * * * <script src="http://code.activestate.com/js/jquery-1.2.1.js"
type="text/javascript"></script>

* * * * <script language="javascript" type="text/javascript">
* * * * * * function onLoad() {
* * * * * * * * var frame1 = $("#frame1");
That looks like something from jQuery, so ask in a jQuery forum.
--
Rob
Sep 28 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ibm_97 | last post by:
Session 1: $db2 +c db2 => set current isolation = UR db2 => select * from t T1 ------ ABC
5
by: Prem Mallappa | last post by:
Hi everybody here is my code to print all nonblank character on Input.. This program according to my knowledge should run till i press Ctrl+D but,,, this is parsing the input untill i press...
6
by: Lloyd Dupont | last post by:
I'm creating a new web site with a master page. Imy master page is using a stylesheet Now the problem is: what if I don't want all page in the same directory but have some kind of hierarchy, like...
5
by: Mario Krsnic | last post by:
Hello everybody, This works in vb.net. The value of n increments: Public Class Form1 Dim n% Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
5
by: NvrBst | last post by:
I have a bunch of variables I'd like to assign... is it possible to do it in 1 line. IE This is how I do it now int sally, jim, bill, fread, sam; sally = jim = bill = fread = sam = 5;
5
by: hn.ft.pris | last post by:
Hi: I'm a beginer of STL, and I'm wondering why none of below works: ######################################################################## .......... string str("string"); if ( str == "s" )...
4
by: hn.ft.pris | last post by:
####################################### ........ void argParser(int, char**); int main(int argc, char** argv){ argParser(argc, argv); return 1; } void argParser(int argc, char** argv){
4
by: dwadish | last post by:
I am a beginer to vb.net Guys my problem is how i can configure asp.net with windows 2003 server i am installed vs.net 2003 but i can't work with asp.net application failure message is web...
7
by: Helpful person | last post by:
I am new to Javascript and have a fairly straightforward question. I am trying to use an image as a link to open a new page with the onmouseclick event. In general this seems to work fine with...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.