It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

please help, im desperate! html/js + iframe!

please help, im desperate! html/js + iframe!

Postby chii on Fri Sep 21, 2007 9:13 am

hi!

i was wondering if someone could help me with an urgent problem!
resently i have been taking over a wabpage of which i was only to makeover the firstpage. when i did this i got a lot of problems with the rest of the site. its a really old site, which was using framelayout until i changed the frontpage.
so now i obviosly need a solution! quickly!

im doing it like this,shortversion.

<a href="next.html" onclick="func()">thelink</a>

so im sending a request to js at the same time as im moving forward til the next htmlpage. in the external js i do as fallows.

function next()
{
document.getElementById('inladdare').src="anotherpage.htm";
}

this is were the problem starts i think.
js doesnt know that ive switched htmlpage. it thinks that "document" is the frontpage, and thats why it cant find the iframe,'inladdare', in which i want to load the new html, "anotherpage.htm"

so, now i wonder if its even possible to do something like this? or does anybody have a better idea?
i cant use php, because its not supported. neigther can i manually change all of the dokuments, theres simply too many. and if i do so itll only cause more problems than if i leave it be.

please! im desperate and very greatful for whatever help i can get!
thanx!
//chii
chii
 
Posts: 4
Joined: Fri Sep 21, 2007 8:57 am

Postby bobbyblades on Fri Sep 21, 2007 10:41 am

I don't understand that code at all, your trying to change the src of a frame while clicking on a link? that will never work the way it's coded because nothing is stopping the page from navigating to the next page. try:
<a href="javascript:void(0)" onclick=func()>
this way the link will be disabled and will not navigate the browser to the href
User avatar
bobbyblades
50+ Club
 
Posts: 85
Joined: Fri Aug 24, 2007 8:38 pm
Location: hawaii or bust

Postby chii on Fri Sep 21, 2007 10:49 am

the thing is that i dont want to stop the changeing of page, thats exactly what i want!
but. when it comes to js. the document.getelementbyid() will not find the object thats in the new page.
this is what i have a problem with i think. i wonder how i can get js to get the document element of the new page instead of the firstpages. if its doable? or can i get around it somehow?
chii
 
Posts: 4
Joined: Fri Sep 21, 2007 8:57 am

Postby bobbyblades on Fri Sep 21, 2007 10:59 am

well thats because the page is not loaded untill after the function call in the onclick handler, thats why if you put alert("somthing") as the the function which handles the onclick, it blocks untill you press ok then loads the new page. you cannot logically do what your trying to do in a top level window.
User avatar
bobbyblades
50+ Club
 
Posts: 85
Joined: Fri Aug 24, 2007 8:38 pm
Location: hawaii or bust

Postby chii on Fri Sep 21, 2007 11:05 am

no, thats what i wanted to know. but surely there has to be a way of making it work!
maybe put the link in some sort of variable and then call the function in the new page were the objekt exists n the document is the accurate?
i welcome every idea of how to put html into a part of another htmlfile when a link is clicked!

i appriciate u trying to help!
thanx! =)
chii
 
Posts: 4
Joined: Fri Sep 21, 2007 8:57 am

Postby chii on Fri Sep 21, 2007 11:08 am

isnt it possible to choose from which htlm u want to get the document element from? somehow...

maybe something like:
somehtml.document.getelementbyid('thingie').src="blabla.html";

i know this doesnt work, but maybe im just doing it wrong
chii
 
Posts: 4
Joined: Fri Sep 21, 2007 8:57 am

Postby bobbyblades on Fri Sep 21, 2007 6:47 pm

well I wish you luck in your quest to defy all logic and call a function in the old document after you have navigated to a totally new document in the top level window. keep the dream alive! LOL seriously though write down the entire code and let me have a crack at finding out what the problem is, maybe I'm just not understanding what your trying to do.
User avatar
bobbyblades
50+ Club
 
Posts: 85
Joined: Fri Aug 24, 2007 8:38 pm
Location: hawaii or bust


Who is online

Users browsing this forum: No registered users and 11 guests