JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old July 12th, 2006, 12:51 PM
escobardo escobardo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 2 escobardo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 24 m 53 sec
Reputation Power: 0
Arrow Response from form submit using hidden iframe is a new window

Hi,

I upload a file using a hidden iframe on a main page, the target of the form indicates the hidden iframe.
The file is uploaded with success but the response not return to iframe, the page response opens in a new window. The page response, shouldn't open in a hidden iframe?
I need to open in the hidden iframe for the page response body onload access a javascript function on the main page.

Thanks all.

Claudio Escobar

Reply With Quote
  #2  
Old July 13th, 2006, 05:33 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 956 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 650865 Folding Title: Super Ultimate Folder - Level 2Folding Points: 650865 Folding Title: Super Ultimate Folder - Level 2Folding Points: 650865 Folding Title: Super Ultimate Folder - Level 2Folding Points: 650865 Folding Title: Super Ultimate Folder - Level 2Folding Points: 650865 Folding Title: Super Ultimate Folder - Level 2Folding Points: 650865 Folding Title: Super Ultimate Folder - Level 2Folding Points: 650865 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 8 h 23 m 32 sec
Reputation Power: 4
Send a message via ICQ to Itsacon
Could you supply us with the code?

Very hard to debug otherwise
__________________
This is my code. Is it not nifty?

"The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools."
---Douglas Adams


Join the Itsacon fanclub!    
Zero Tolerance: Spammers banned so far: 264

Reply With Quote
  #3  
Old July 13th, 2006, 01:05 PM
escobardo escobardo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 2 escobardo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 24 m 53 sec
Reputation Power: 0
This is a main page with ajax structure:
Code:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>

Sco Title: <span id="scoTitle">${sessionScope.scoTitle}</span>&nbsp;

<div id="editorBody"/>

<iframe id="iFrame" name="iFrame" src=""></iframe>

<script language="javascript">

var newScoDescriptionHtml =
    "Palavras-Chave: <input type='text' id='sceneWordKey'/>"
  + "Descricao: <textarea id='sceneDescription'></textarea>"
  + "<input type='button' value='Avancar' onclick='javascript:addScoDescription()'>";
  
var scenesHtml =
    "<div id='editorScenes'>"
  + "<div id='editorScenesCreated'>"
  + "<span>Created Scenes:</span>"
  + "<span id='scenesList'/>"
  + "</div>"
  + "<div id='editorScenesNumber'> Number of Scenes:"
  + "<span id='currentScene'>99</span> / <span id='scenesCount'>99</span>"
  + "&nbsp;&nbsp;Number of Page: <span id='currentPage'>99</span>"
  + "<hr/></br>"
  + "<div id='editorScenesBody'>"
  + "<span id='sceneBody'></span>"
  + "</div></div></div>"

  + "<%-- Editor Command Buttons --%>"
  + "<div id='teste'><div id='buttonPanel'>"
  + "<span>Click on a button to create a new scene of a desired type</span><br/>"
  + "<input type='button' value='Text'      onclick='javascript:newTextScene()'/>"
  + "<input type='button' value='Media'     onclick='javascript:newMediaScene()'/>"
  + "<input type='button' value='New Page'  onclick='javascript:newPage()'/> </br>"  
  + "<input type='button' value='Finish'    onclick='javascript:finishSco()'/>"
  + "</div></div>";

var mediaScene =
    "<form name='UploadMedia' id='iframeForm' target='iFrame' action='/teobaldo2/UploadMedia.do' method='post' enctype='multipart/form-data'>"
  + "<input type='file' name='mediaFile'/>"
  + "<input value='ok' type='submit'/></form>";

var textScene = 
    "Scene Text:<textArea rows='3' cols='30' id='sceneText'></textarea>"
  + "<input value='ok' type='submit' onclick='javascript:saveTextScene()'/>";
</script>

<script language="javascript" src="js/ajax/ajax-base.js"></script>
<script language="javascript" src="js/ajax/scenes-sco-editor.js"></script>


This is a javascript that control a ajax scheme:

Code:
// conters to control a sco editor
var scenesCount = 0, currentScene = -1, currentPage = 0;
// control a sceneBody
var newPageState = false, pageSceneBody = 0, sceneSceneBody = 0;
// state variables
var creatingScoDescription = true, creatingTextScene = false, 
    creatingMediaScene = false, sceneCreated = false;
// wordkey and description of the SCO
var wordkey = "", description = "";
// array of pages that contains in each position a scenes array
var pages = new Array();

// initialize the first page
newPage()

// makes sure the GUI starts correctly for the initial state
updateView();


/* updates the screen components acordingly to the editor state */
function updateView() {
    if ( creatingScoDescription ) {
        document.getElementById( "editorBody" ).innerHTML = newScoDescriptionHtml;
    } else {
        document.getElementById( "editorBody" ).innerHTML = scenesHtml;
        document.getElementById( "scenesCount" ).innerHTML = scenesCount;
        document.getElementById( "currentScene" ).innerHTML = currentScene + 1;
        document.getElementById( "currentPage" ).innerHTML = currentPage + 1;

        if ( creatingTextScene ) {
            document.getElementById( "sceneBody" ).innerHTML = textScene;
        } else if ( creatingMediaScene ) {
            document.getElementById( "sceneBody" ).innerHTML = mediaScene;
        } else if ( sceneCreated ) {
            if ( newPageState ) {
                pageSceneBody = currentPage - 1;
            } else {
                pageSceneBody = currentPage;
            }
            document.getElementById( "sceneBody" ).innerHTML = 
               "<pre>" + pages[pageSceneBody].scenes[sceneSceneBody].text + "</pre>";
        } else {
            // what is the default sceneBody ?
        }

        updateScenesList();
    }
}

function updateScenesList() {
    var html = "<ul>";
    for ( i = 0; i < pages.length; i++ ) {
        for ( j = 0; j < pages[i].scenes.length; j++ ) {
            html += "<li>" + pages[i].scenes[j].name + "</li>";
        }
    }
    html += "</ul>";

    document.getElementById( "scenesList" ).innerHTML = html;
}

function addScoDescription() {
    wordkey = document.getElementById( "sceneWordKey" ).value;
    description = document.getElementById( "sceneDescription" ).value;

    creatingScoDescription = false;

    updateView();
}

function newTextScene() {
    if ( creatingTextScene || creatingMediaScene ) {
        alert("Exists a scene in creation state.");
    } else {
        scenesCount++;

        clearState();
        creatingTextScene = true;

        updateView();
    }
}

function newMediaScene() {
    if ( creatingTextScene || creatingMediaScene ) {
        alert("Exists a scene in creation state.");
    } else {
        scenesCount++;

        clearState();
        creatingMediaScene = true;

        updateView();
    }
}

function saveTextScene() {
    var stringLength = "";
    var scene = new Object();

    scene.text = document.getElementById( "sceneText" ).value;

    for ( i = 0; i < pages[currentPage].scenes.length; i++ ) {
        stringLength += pages[currentPage].scenes[i].text;
    }

    if ( stringLength.length > 400 ) {
        alert( "Each page can't have more than 400 characters." );
    } else {
        scene.name = scene.text.substring( 0, 14 ) + "...";

        pages[currentPage].scenes[pages[currentPage].scenes.length] = scene;
        pages[currentPage].scenes[pages[currentPage].scenes.length].type = "text";
        currentScene++;

        clearState();
        sceneCreated = true;
        newPageState = false;
        sceneSceneBody = pages[currentPage].scenes.length -1;
    }
    
    updateView();
}

function saveMediaScene() {
    var scene = new Object();

    scene.text = document.getElementById( "sceneText" ).value;
}

function newPage() {
    if ( creatingTextScene || creatingMediaScene ) {
        alert("Exists a scene in creation state.");
    } else {
        currentPage = pages.length;
        pages[currentPage] = new Object();
        pages[currentPage].scenes = new Array();

        newPageState = true;

        updateView();
    }
}

// this function is activated in the page response's body onload of the mediaUpload form, 
// for setting the especifics values on scenes array
function mediaResponse() {
    alert("**The Page Response was openned**");
}


This is a page response:
Code:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<html><body onload="javascript:autoClose()">
<script>
  function autoClose() {
      mediaResponse();
      setTimeout("window.close()",1500);
  }
</script>
<center><div>UPLOAD SUCCESS</div></center>
</body></html>


This page response don't open in a iframe. Open in a new window.
If u need more information, post them please for i explain better.

Thanks for your attention.

Claudio Escobar Apparicio.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Response from a hidden iframe is a new window


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway