Getting Javascript to work with my page?

I have an ASP.NET Page

I have placed the following script in my head:

  <script type="text/javascript">
    <!--
    function getElement(aID)
    {
        return (document.getElementById) ?
            document.getElementById(aID) : document.all[aID];
    }

    function getIFrameDocument(aID){
        var rv = null;
        var frame=getElement(aID);
        // if contentDocument exists, W3C compliant (e.g. Mozilla)

        if (frame.contentDocument)
            rv = frame.contentDocument;
        else // bad IE  ;)

            rv = document.frames[aID].document;
        return rv;
    }

    function adjusticustomers()
    {
        var frame = getElement("icustomers");
        var frameDoc = getIFrameDocument("icustomers");
        frame.height = frameDoc.body.offsetHeight;
    }
    //-->
    </script>

and then within my page:


<iframe id="icustomers" onload='adjusticustomers();' runat="server" src="..."> </iframe>

But I am getting the following error:

Creator.master(85,0): error BC30456: 'adjusticustomers' is not a member of 'ASP.creator_master'.
Creator.master(85,0): error BC30037: Character is not valid.

Any ideas on how I resolve this?
directxBOBAsked:
Who is Participating?
 
Praveen VenuTechnical Project ManagerCommented:
Since you have made it run at server it will consider onload as server side function.

Instead of that make it like

<iframe id="icustomers" runat="server" src="..."> </iframe>

and in the Page_Load on the server side

icustomers.Attributes.Add("onload","adjusticustomers();")
0
 
rseabirdCommented:
You put 'runat="server" inside the ifram tag. I suppose that will not work. It should be either client side (use the javascript) or server side (use .net code).
0
 
directxBOBAuthor Commented:
I'm getting an error message (javascript side) which is saying the icustomers is undefined.

I am using IE7
0
 
Praveen VenuTechnical Project ManagerCommented:
So it means your code not able to get the icustomers frame


0
 
directxBOBAuthor Commented:
Anyway to figure out why? All pages are contained within the same directory. As you can see my ID for the page

<iframe id="icustomers" onload='adjusticustomers();' runat="server" src="..."> </iframe>

does match up with

icustomers.Attributes.Add("onload","adjusticustomers();")

So i am wondering what the potential reasons for the JavaScript not working might be.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.