View Single Post
Old 08-11-2010, 03:21 PM   PM User | #3
Michael_
New to the CF scene

 
Join Date: Jan 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Michael_ is an unknown quantity at this point
Code:
location.href = "#Factor" + document.getElementById("SearchNumber_txt").value
didn't work
But maybe it's because I can't put it in the pop up window. I tried placing some Javascript in the pop up window and the whole web page crashed. I can still refer to it using the opener method though.
Is my problem something to do with the code I use to set the anchor? I use:
Code:
FactorsFound.push("<a name = 'Factor'" + Input2 + "><b>The Factors of " + Input2 + " are:</b></a><p style = 'margin: 0, 0, 25px, 0; position:relative; left:20px;'>")
Does this definately create an anchor with the name "#Factor" + Input2
Input2 is a number that increments by 1 each time the loop is executed.

I don't think it is the creating of the anchors, but could someone please confirm that thought for me.
Also, I tried reloading the page, but that doesn't work because the page was created by javascript. Would reloading the page, by running the DisplayFactors function work because then I could link to the anchor. I have made links before that do this.
Here is the full DisplayFactors function.
Code:
function DisplayFactors(FactorsFound, Input, Maximum, ShowFactors, ShowPrimeFactors){
	//                        Instead of opening the window here, could I open it at the end after everything has been placed in the window, then I could open it to the anchor.
	FactorsWindow = window.open("", "", "location = no, menubar = no, personal = no, scrollbars = yes, status = no, toolbar = no, resizable = no, width = 580%, height = 600%, left = 720%, top = 100%")
	FactorsWindow.document.write("<div id = 'TheHeader' style = 'position: fixed; left: 0; top: 0; width: 100%; height: 15%; z-index: 2; background-color: white; border-bottom: 3px dashed black;'><table style = 'position: relative; left: 2%; top: 25%; font-size: 24px; font-weight: bolder; text-decoration: underline;'><tr><td>The Factor Finding Window</td></tr></table><table align = 'right' style = 'position: relative; top: -25%;'><tr><td>Search For The Number:</td></tr><tr><td><input type = 'text' id = 'SearchNumber_txt' maxlength = '12' onkeyup = 'opener.Search()'/></td></tr></table></div>")
	FactorsWindow.document.write("<div id = 'TheBody' style = 'position: absolute; left: 0; top: 20%; width: 100%; height: 80%; z-index: 1; background-color: white;'>")
	FactorsWindow.location.hash += "#Top"
	if(ShowFactors){
		if(Input == Maximum){
			FactorsWindow.document.write("<title>Factors of " + Input + "</title>")
		}else{
			FactorsWindow.document.write("<title>Factors of Numbers Between " + Input + " and " + Maximum +"</title>")
		}
		FactorsWindow.document.write(FactorsFound.join("<br />"))
	}else{
		if(ShowPrimeFactors){
			FactorsWindow.document.write("<title>Prime Factors Of " + Input + "</title>")
			FactorsWindow.document.write(FactorsFound.join(""))
		}else{
			FactorsWindow.document.write("<title>Prime Numbers Between " + Input + " and " + Maximum + "</title>")
			FactorsWindow.document.write(FactorsFound.join("<br />"))
		}
	}
	FactorsWindow.document.write("</div>")
}
I'm as confused as my answer is to read.
Michael_ is offline   Reply With Quote