Link on Iframe should change div on page

Discussion in 'JavaScript' started by media12, Jun 14, 2007.

  1. #1
    I have a page where I load an iframe and in that iframe, i have an onclick that looks like this

    onclick="javascript:ajaxpage('http://localhost/project/includes/php/add-images.php?src=" . $oname . "&dsc=" . $dsc . "', 'add-images');"

    The problem is that the "add-images"-DIV is not in the iframe, it's on the page that loads the iframe, are there any way to make this work, or do I have to find another way of doing it?

    Thanks in advance!
     
    media12, Jun 14, 2007 IP
  2. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #2
    You need to set the target to the iframe.

    To be of more help, I need the code for the ajaxpage() function.
     
    krt, Jun 14, 2007 IP
  3. media12

    media12 Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Here's that function:

    function ajaxpage(url, containerid) {
    	var page_request = false
    	if (window.XMLHttpRequest) // if Mozilla, Safari etc
    	page_request = new XMLHttpRequest()
    	else if (window.ActiveXObject){ // if IE
    	try {
    	page_request = new ActiveXObject("Msxml2.XMLHTTP")
    	} 
    	catch (e){
    	try{
    	page_request = new ActiveXObject("Microsoft.XMLHTTP")
    	}
    	catch (e){}
    	}
    	}
    	else
    	return false
    	page_request.onreadystatechange=function(){
    	loadpage(page_request, containerid)
    	}
    	page_request.open('GET', url, true)
    	page_request.send(null)
    }
    Code (markup):
     
    media12, Jun 14, 2007 IP